Problems with Tkinter and threads

Claus Tondering claus.tondering at gmail.com
Mon Jul 17 06:58:08 EDT 2006


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>>")

In the associated event handler, I do this:

    self.label1.grid_forget()
    self.label2.grid()

This works well if event is generated from a function that is called
through the after() method of the main frame. But when I send the event
from my TCP thread, the system hangs in the call to grid_forget.

Surprisingly, if I replace self.label1.grid_forget() with
self.label1.destroy(), things work well.

What can I do to call grid_forget in this event handler?

--
Claus Tondering




More information about the Python-list mailing list