Why not event-driven packages in other than the main thread?

Paul Rubin http
Fri Sep 15 18:50:20 EDT 2006


Tor Erik <torerik81 at gmail.com> writes:
> I've developed an application were I've used Tkinter for the GUI.
> When I ran the GUI in another thread than the main, it kept locking
> up.  I experienced similar problems with Twisted.

Tkinter is not thread-safe.  You have to synchronize any cross-thread
communication with it.  The way I usually do it is with an "after"
method that checks a communications queue (Queue.Queue object) every
20 msec or so.  Any communication to and from the gui thread is done
through the queue.  There is a recipe like this in the Python Cookbook
and you can probably find it at ASPN.



More information about the Python-list mailing list