Help on multithreading and Tkinter; Linux vs Windows

Discussion in 'Python' started by corrado, May 21, 2004.

  1. corrado

    corrado Guest

    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
     
    corrado, May 21, 2004
    #1
    1. Advertising

  2. corrado

    Eric Brunel Guest

    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
     
    Eric Brunel, May 24, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mark English

    Multithreading tkinter question

    Mark English, Dec 15, 2004, in forum: Python
    Replies:
    3
    Views:
    638
    Eric Brunel
    Dec 17, 2004
  2. Replies:
    9
    Views:
    374
    Antoninus Twink
    May 17, 2008
  3. jurij
    Replies:
    6
    Views:
    346
    jurij
    Jun 14, 2008
  4. Hidekazu IWAKI
    Replies:
    1
    Views:
    418
    Peter Otten
    Dec 14, 2009
  5. Hidekazu IWAKI
    Replies:
    0
    Views:
    553
    Hidekazu IWAKI
    Dec 15, 2009
Loading...

Share This Page