From: Guido van Rossum <guido@CNRI.Reston.Va.US> Subject: Re: Tkinter mainloop and threads in win32 Date: Tue, 22 Sep 1998 03:33:24 GMT > Hi, I am trying to write an TkInter app which has a listbox that is altered > from time to time. So what I do is start_new_thread which listens to a port > and whenever something arrives it write it to the listbox. Sounds trivial. > The code looks somewhat like this: > > import thread > > class MyGui(Frame): > ... > > def listenToPortThreadProc(): > ... > > gui=MyGui() > thread.start_new_thread(listenToPortThreadProc, ()) > gui.mainloop() > > When running this code and sending data through the port I first have to click > several times on the listbox before the list is updated. > It looks as if the spawned thread has almost no priority (kind of starvation). > Even the easier example where the listenToPortThreadProc just updates the > listbox directly reacts the same. > Is this just a win32 problem? > Any hints... > > Clemens > BTW: WinNT4.0 SP3, Python 1.5.1, Tcl/Tk8.0(latest) Sorry, threads and Tkinter (or threads and Tcl/Tk!) are not usable together. In 1.5.2 (in alpha for PSA members!) this will work, sort of, but there will still be problems, especially on Windows. I wish I could help you, but Ousterhout has made it clear that Tk will (probably) never be thread-safe :-( --Guido van Rossum (home page: http://www.python.org/~guido/)