Tkinter's event queue

As we discussed in Chapter 10Creating Automated Tests with unittest, many tasks in Tkinter, such as drawing and updating widgets, are done asynchronously, rather than taking immediate action when called in code. More specifically, the actions you perform in Tkinter—clicking a button, triggering a key bind or trace, resizing a window—place an event in the event queue. On each iteration of the main loop, Tkinter pulls one event from the queue and executes it.

Tasks in the event queue are roughly prioritized as regular or do-when-idle (often just called idle tasks), meaning they are to be run when every regular task in the queue has been done. Most drawing or widget-updating tasks are idle tasks, while actions like callbacks ...

Get Python GUI Programming with Tkinter now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.