467,912 Members | 1,588 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,912 developers. It's quick & easy.

Help on multithreading and Tkinter; Linux vs Windows

Hello

I have an application running several thread to display some financial
data;
basically I have a thread displaying HTML tables by means of Tkhtml,
another implementing a scrolling ticker based on a Text widget with
embedded windows and a thread running the Tkinter mainloop plus
several other thread dealing with the scheduling of the contents and
the acquisition of data but not using graphic widgets.
I run the same code on Linux and Windows; I have no problems on Linux
while on Windows everything get stucked when I tried to scroll the
ticker, it looks like I'm blocked in mywidget.xview(SCROLL,1,UNITS);
at this time the graphic of the application freezes while all the rest
goes on running.
I tried several other strategies, like having the ticker thread and
the table displaying thread sending event to the mainloop to perform
Tkinter methods call in callbacks instead of calling the methods
themselves, but nothing seems to change. If I run root.update() after
scrolling the ticker, I can see it moving a bit, but after some loops,
I get the same frozen status.

Is there anyone who can help me? I've already tried the
Tkinter-discuss mailing list but I got no answer.
I supposed Tkinter worked the same way under Windows and Linux but it
does not look like it's so; is there any paper explaining the
differences between the behaviour on the two operating systems? For
instance on Windows I also had problem with iconify and with the
button highlight, which is Windows standard whatever setting you try.

Any help is really appreciated.

Thanks in advance

Corrado Clementi
Jul 18 '05 #1
  • viewed: 3489
Share:
1 Reply
corrado wrote:
Hello

I have an application running several thread to display some financial
data;
basically I have a thread displaying HTML tables by means of Tkhtml,
another implementing a scrolling ticker based on a Text widget with
embedded windows and a thread running the Tkinter mainloop plus
several other thread dealing with the scheduling of the contents and
the acquisition of data but not using graphic widgets.
I run the same code on Linux and Windows; I have no problems on Linux
while on Windows everything get stucked when I tried to scroll the
ticker, it looks like I'm blocked in mywidget.xview(SCROLL,1,UNITS);
at this time the graphic of the application freezes while all the rest
goes on running.
Like many other GUI toolkits, it seems that Tkinter doesn't like to be called
from several threads in the same application. The fact that it works on Linux is
what is suprising to me: I already tried to do a similar thing on Linux and
finally gave up, because I experienced many lock-ups like you do.

The solution is always the same: use only one thread to manage the GUI,
preferably the main one, and use a combination of Tkinter GUI events posted via
event_generate and Queue's to pass information from secondary threads to the
GUI. It messes up the code a bit, but it's the only way we've found to avoid the
lock-up's you're experiencing.

[snip] Is there anyone who can help me? I've already tried the
Tkinter-discuss mailing list but I got no answer.
I supposed Tkinter worked the same way under Windows and Linux but it
does not look like it's so; is there any paper explaining the
differences between the behaviour on the two operating systems? For
instance on Windows I also had problem with iconify and with the
button highlight, which is Windows standard whatever setting you try.


Try the tcl/tk documentation at http://www.tcl.tk/man ; it of course describes
the tcl commands corresponding to the Tkinter classes and methods, but has much
more details about the differences between the supported platforms than any
Tkinter documentation I know. But you're touching quite a deep problem here: the
mix of GUI and threads is a tough issue, and the problems you experience may
depend not only on tk or Tkinter, but also on how Python manages threads and how
the underlying system supports them. I fear your best source of info on this
matter will be newsgroups like this one...

HTH
--
- Eric Brunel <eric (underscore) brunel (at) despammed (dot) com> -
PragmaDev : Real Time Software Development Tools - http://www.pragmadev.com

Jul 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Dennis Sylvester | last post: by
3 posts views Thread by anuradha.k.r | last post: by
7 posts views Thread by SeeBelow | last post: by
7 posts views Thread by Justin Ezequiel | last post: by
2 posts views Thread by Mark English | last post: by
42 posts views Thread by =?ISO-8859-1?Q?Tom=E1s_=D3_h=C9ilidhe?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.