threads and Tk

Fredrik Lundh fredrik at pythonware.com
Tue Sep 21 18:31:57 EDT 1999


Eric I. Arnoth <earnoth at home.com> wrote:
> How do the Tk mainloop() and transient() methods interact
> with python's built in threading capabilities?

you're on thin ice here...

here's a simpler solution (which is guaranteed to work).

1. run the server thread as usual.  when you receive
data, push them to a Queue object (as provided by
the module with the same name).

2. over in Tkinter land, running under the main thread,
use an idletask to poll the queue (using get_nowait) every
100ms or so, and display the dialogue as necessary.

(personally, I'd forget about threads, and use asynclib
instead, but that's another story).

hope this helps!

</F>





More information about the Python-list mailing list