threads and Tkinter

Petr Klyushkin petrk at pochtamt.ru
Tue Jul 23 04:15:19 EDT 2002


Hello again!

I have one more question about Tkinter. This time it is related with
threads.  I have a program which uses Tkinter as its GUI toolkit.  It
runs a separate "worker" thread for doing some time-consuming
operation.  Sometimes worker thread has to update GUI.

For now I've solved this problem with pipes.  Worker thread writes
data to pipe and GUI thread waits for it with Tkinter's
createfilehandler() and draws them on screen.  This solution seems to
me to be rather cumbersome.  Moreover, it doesn't work on Windows,
because it supports select() only on sockets.

I want to update GUI directly from worker thread, and this requires
Tkinter to be thread-safe.  I have tcl/tk 8.3.4 and Python 2.2 with
tkinter all compiled with thread support.  I've seen sources of
_tkinter and as far as I can understand, it uses a lock to block calls
to Tkinter.  Does it mean that I can fearlessly do Tkinter calls in
both threads and Tkinter will do proper blocking for me?

I'm sorry if this explanation seems to you rather confusing, English
isn't my native language...


-- 
                                                             C'ya, Peter.
       --=[petrk at pochtamt.ru]=--=[http://petrk.pochtamt.ru]=--
        --=[ICQ 89449080]=--=[Jabber dassburger at jabber.ru]=--



More information about the Python-list mailing list