O'Reilly logo

Tkinter GUI Application Development Blueprints - Second Edition by Bhaskar Chaudhary

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

Tkinter and thread safety

Tkinter is not thread safe. The Tkinter interpreter is valid only in the thread that runs the main loop. Any calls to widgets must ideally be done from the thread that created the main loop. Invoking widget-specific commands from other threads is possible but is not reliable.

When you call a widget from another thread, the events get queued for the interpreter thread, which executes the command and passes the result back to the calling thread. If the main loop is running but not processing events, it sometimes results in unpredictable exceptions.

In fact, if you find yourself calling a widget from a thread other than the main loop, chances are that you have not separated the visual elements from the underlying data structure. ...

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