Problems with Tkinter and threads

Eric Brunel eric_brunel at despammed.com
Mon Jul 17 08:55:16 EDT 2006


On Mon, 17 Jul 2006 12:58:08 +0200, Claus Tondering  
<claus.tondering at gmail.com> wrote:

> My Tkinter application has to receive events from a TCP connection. I
> have chosen to do this in the following manner:
>
> The TCP communication takes place in a separate thread. When I receive
> data, I generate an event in the Python application thus:
>
>     app.event_generate("<<myevent1>>")

This is where the problem is: if you do just a event_generate without  
specifying the 'when' option, the binding is fired immediately in the  
current thread. To be sure that an event is created and that the thread  
switch actually happens, do:

app.event_generate("<<myevent1>>", when='tail')

and things should work fine.

HTH
-- 
python -c "print ''.join([chr(154 - ord(c)) for c in  
'U(17zX(%,5.zmz5(17l8(%,5.Z*(93-965$l7+-'])"



More information about the Python-list mailing list