Help on multithreading and Tkinter; Linux vs Windows

C

corrado

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
 
E

Eric Brunel

corrado said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top