Gui thread and async jobs.
Diez B. Roggisch
deets at nospam.web.de
Tue May 8 09:00:37 EDT 2007
king kikapu 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.
>
> 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 ?
It depends on the toolkit you use. Qt has thread-safe custom events in 3.x,
and afaik signal/slots (and thus events) are generally thread-safe in 4.x.
So, no problems there.
Diez
More information about the Python-list
mailing list