Tkinter.Canvas thread safety problem?

Zdenek Maxa zdenekmaxa at yahoo.co.uk
Tue Jul 7 08:38:16 EDT 2009


Hello,

I have started a project using Tkinter. The application performs some
regular checks in a thread and updates Canvas components. I have
observed that sometimes the application hangs when it is about to call
canvas.itemconfig() when the thread is about to terminate in the next loop.

Experimenting with this problem for a while, I have compiled a little
example which always reproduces the problem. Commenting out the line 52
(before canvas.itemconfig()), the example always finishes all right,
having the delay there, it hangs.

I would like to ask if you could have a look at the snippet in the
attachment and tell me if that is actually me doing something wrong or
indeed Tkinter thread safety problem and what the workaround could be.

Could you please also comment on wxPython thread safety?

I am using:

Python 2.5.4 (r254:67916, Feb 17 2009, 20:16:45)
[GCC 4.3.3]

2.6.26-1-amd64 #1 SMP Fri Mar 13 19:34:38 UTC 2009 x86_64 GNU/Linux

Thanks in advance,
Zdenek
-------------- next part --------------
A non-text attachment was scrubbed...
Name: tkinter_thread_safety.py
Type: text/x-python
Size: 2278 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20090707/de3e4d7b/attachment.py>


More information about the Python-list mailing list