Version 14 of tkwait

Updated 2017-05-03 06:14:49 by pooryorick

tkwait , a built-in Tk command, runs the event loop while waiting for something to happen (as described by its arguments).

See Also

update considered harmful
On the hazards of entering the event loop.
vwait
Similar to tkwait variable.

Synopsis

tkwait variable name
tkwait visibility name
tkwait window name

Description

While the tkwait is waiting it processes events in the normal fashion, so the application will continue to respond to user interactions. If an event handler invokes tkwait again, the nested call to tkwait must complete before the outer call can complete.

caspian: Remember that tkwait syntax differs from after. With after, you need to enclose a command inside of { and }. To wit:

after 500 {
    puts "hello, world!"
}

With tkwait, there is no need to use { }s. (You will get an error if you do). Instead, you can do something like this:

tkwait ...
puts "hello, world!"

Everything after tkwait... will not be executed until the event occurs.

Gotcha: Global Scoping

"Anyway, it's a little bit confusing that tkwait is 'scope-proof'. ;)" Another reminder to read the man page carefully: "If the first argument is variable (or any abbreviation of it) then the second argument is the name of a global variable and the command waits for that variable to be modified."