Running code in the background with threading

All of the code we have written up to this point in the book can be described as single threaded; that is, every statement is executed one at a time, the prior statement finishing before the next one is begun. Even asynchronous elements such as our Tkinter event queue, though they may change the order in which tasks are executed from how they are written, still execute only one task at a time. This means that a long-running procedure like a slow network transaction or file read will freeze up our application while it runs.

To get around this problem, we need to create a multithreaded application, in which multiple sections of code can be run concurrently without needing to wait for one another. ...

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.