Gui thread and async jobs.

Jarek Zgoda jzgoda at o2.usun.pl
Wed May 9 03:28:17 EDT 2007


king kikapu napisał(a):

> 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.
> 
> Author said that another alternatives exists (by not doing polling)
> but the complexity makes them non-practical for the 90% of ocassions.
> I remember in C# we deal with that sort of things with events/
> delegates.
> Hos the same thing is possible in Python, has anyone any link(s) to
> have a look ?

Another option, although not a silver bullet, is to use a message
dispatcher, like Louie (http://www.pylouie.org/). Unfortunately, the
Louie dispatcher seems to be synchronous, so I wouldn't recommend it for
the environment with "high density" of events. If your application
dispatches a message then sits idle for some time, Louie will fit
perfectly as the queuing of messages will not happen. Otherwise there
would be no advantage other than code simplification. And this counts
always. :)

-- 
Jarek Zgoda

"We read Knuth so you don't have to."



More information about the Python-list mailing list