[pygtk] PyGtk, Standard way to thread?

A.T.Hofkamp a.t.hofkamp at tue.nl
Mon Jun 18 16:54:57 WST 2007


NewbieNoob wrote:
> Hi Everyone
> 
> I have been going around in circles for weeks now, I would love some help.
> 
> Is there a standard way to thread or otherwise divide tasks with PyGtk.
> 
> I know you can use:
> -the thread module
> -the threading module
> -the Queue module
> -the Gtasklets module with pseudo threads
> -the time module to time different tasks.

Twisted seems to be missing in your list, a framework designed for 
asynchronous co-operative event-based programming.
Designed for writing network-communication programs (example chat servers), 
but it can deal with event-based GUI's with a few additional lines of code.

> I want to control instruments through a serial port, plot data from them and
> still have a responsive GUI. I am pretty sure I will need to thread these
> tasks.

The basic idea is to wait for an event that 'something of interest' happened 
(like you do with GUI programming), handle the event, if necessary, set up new 
handlers, and wait again.
In Twisted "something of interest" is not limited to the GUI, but it can also 
come from a serial port, a network connection, another program, etc etc.

URL for more info: http://www.twistedmatrix.com/

Albert



More information about the pygtk mailing list