O'Reilly logo

Tkinter GUI Programming by Example by David Love

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using threads

When writing a Python application, all of the code will run in a single thread by default. This means that, as you read down a file, each line will be carried out one at a time. A piece of code cannot run if there is another piece above it which is executing a large task.

If we wanted to carry out multiple tasks at the same time, there are a couple of different ways we could go about doing so. One way is the use of a thread. When using a thread, the operating system will be able to quickly switch between two running pieces of code so quickly that it appears as if they are being executed at the same time. This means that if you have a function which takes a lot of processing, you are able to do multiple smaller tasks in the time ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required