[Tkinter-discuss] Threads and GUI

mkieverpy at tlink.de mkieverpy at tlink.de
Wed Jan 23 11:50:51 CET 2008


Hello Bob,

You wrote:
>Is there anything that is OK for a thread to do to the GUI?  Like  
>would just calling .update() on a Button() be OK?  It seems to work,  
>but is it OK?

>I'm calling it on a "Stop" button, specifically, in the thread every  
>quarter second, instead of peppering the code with updates() to give  
>the button a chance to set it's IntVar value and then stop everything  
>when the code gets around to checking that.

From what I remember everybody says: Don't do that!
Some refs I found googling for 'tkinter and threads':

A clear warning
  http://mail.python.org/pipermail/tkinter-discuss/2005-February/000313.html
  (the cited reference is dead, though)
  In the following answer is a small example using threading.

Another example using thread and Queue (from effbot):
  http://effbot.org/zone/tkinter-threads.htm

I have used a solution from Mark Lutz (Programming Python/O'Reilly)
but just for popup dialogs that block the GUI while a thread
is running (communicating via a simple variable).
This might be applicable to your scenario, too.

In a socket testing application I have used 'after' in the GUI thread
to look at a common buffer if new data have arrived.


BTW have you found some info regarding your signals problem?

Hope this helps,
Matthias Kievernagel
(mkiever/at/web/dot/de)


More information about the Tkinter-discuss mailing list