Gui thread and async jobs.

Grant Edwards grante at visi.com
Wed May 9 10:58:05 EDT 2007


On 2007-05-08, king kikapu <aboudouvas at panafonet.gr> wrote:

> Hi, i am reading the book "Python Cookbook, 2nd edition" and i
> encountered a very handy recipe, the one that is called
> "Combining GUIs and Asynchronous I/O with Threads"
>
> It is talking about retain a main GUI thread, doing async work
> with worker threads and have both talk through a Queue object
> to dispatch their messages, so the main (GUI) thread remain
> responsive. It has a very good example by using Tkinter and Qt
> that is indeed working. The only point that make me wonder is
> that the QUI thread has to use some polling to check for
> messages in the Queue.

It sounds to me like Qt is missing some rather important
features and/or convenience functions.  In other toolkits (e.g.
wxPython), invoking GUI methods/functions from non-GUI threads
is trivial and involves no polling by the GUI thread.

For example, if in a wxPython application you wanted to call
someGUIobject.method(foo,bar) from a non-GUI thread you just do
this:

   wx.CallAfter(someGUIobject.method,foo,bar)

If you look under the covers there is a queue involved, but
it's nothing the user has to poll or worry about.
   
-- 
Grant Edwards                   grante             Yow! Can I have an IMPULSE
                                  at               ITEM instead?
                               visi.com            



More information about the Python-list mailing list