tkwait , a built-in Tk command, runs the event loop while waiting for something to happen (as described by its arguments).
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.
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."