`new_root.mainloop()` doesn’t make main window unresponsive

Though you’re running a subsidiary event loop (really don’t do that!) it still shares the same registry of event handlers as the outer loop, so events coming in are handled in the inner loop just as in the outer one. (There’s a common piece of low-level event handling code that reaches deep into the OS to do the event processing efficiently. That code, the notifier, is stuff that very few people should ever touch; it’s tricky because it merges some really weird and disparate event sources while also working around a bunch of strange bugs on some platforms.) The event_loop method returns once all windows are deleted. It literally calls the low level event processing engine (the API call is Tcl_DoOneEvent()) with appropriate flags, and does that in a while loop (until the number of existing windows drops below 1; that’s exactly what it is waiting for). This is why you probably shouldn’t count on it terminating and absolutely shouldn’t nest it in a GUI callback.

Leave a Comment