python threading

Alex Martelli aleax at aleax.it
Tue Apr 16 14:56:42 EDT 2002


On Tuesday 16 April 2002 20:39, Geoffrey Talvola wrote:
	...
> Don't most GUI toolkits have some way to post an event to the main GUI
> thread's event loop from another thread?  wxPython has wxPostEvent()
> which does this.

I don't know of any Tkinter or PyQt equivalent.  I hope somebody can
enlighten me about those, as they're the toolkits I need to use.


> So you could write a wrapper class around Queue that posts a "wakeup"
> event to the main GUI thread after an item is added to the queue.  The
> event handler for the "wakeup" event would process whatever items had
> been added to the Queue and then return control to the event loop.

<nod> yep.  And figure out something similar for asyncore/asynchat or
other packages that use a select -- that would be just the ticket.  All
the modification needed to Queue would be an optional callable to call
when the queue transitions from empty to non-empty -- different ones
could be supplied for various GUI kits, async*, etc.


Alex





More information about the Python-list mailing list