create a nearly invisible widget -- a 1x1 frame, for example -- and place it somewhere unobtrusive, like a corner of the app. When you get a button click, do a grab on that widget. The grab will funnel all event to that widget until you release the grab.
Block Tcl/Tk button from multiple clicks
Question
I need a function similar to "tk busy" available under tcl/tk 8.6, that is accept only the first click on a button, and ignore further clicks until the execution of the invoked command has finished. Unfortunately, I have to work with 8.5.9...
I already tried binding a custom proc single_invoke that looks at a global variable set to 1 in my invoked proc. This does not work as apparently the events are queued, so that the second click will be invoked after my proc returns (and the global is set back to 0...)
Update (following the solution in the answers)
proc on_button_click {} {
grab .lExistingLabel
#lengthy code
update; #to release any queued events
grab release .lExistingLabel
}
Thanks!
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow