[pygtk] PyGtk, Standard way to thread?

Seltzer squabbit7 at gmail.com
Sun Jun 17 05:30:07 WST 2007

You can use the threading module to create a thread class, and then call its
functions, etc.
something like:

class my_thread( threading.Thread ):
   def __init__( self, channel, details ):
      threading.Thread.__init__ ( self )   ##you need this
      self.my_args =3D "hello"
   def run ( self ):  ## this is them method that gets called when you
      ....            ##call start() on your thread object.
      do something

allot of people use an infinite loop in their run method, something like
"while not self.kill"
and have kill as an event object,

or if you just want to thread one function...

make sure you use the gtk threads enter, and threads leave methods  if your
doing anything with the
interface, as well as gtk threads init some where before you start gtk main.


On 6/16/07, NewbieNoob <optomatic at rogers.com> 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.
> 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.
> It seems that most people think threads are very difficult or just plain
> evil. Is there a fairly straight forward way to accomplish these sorts of
> operations?
> I would really appreciate any help you could provide-Patrick
> --
> View this message in context:
> http://www.nabble.com/PyGtk%2C-Standard-way-to-thread--tf3934204.html#a11=
> Sent from the Gtk+ - Python mailing list archive at Nabble.com.
> _______________________________________________
> pygtk mailing list   pygtk at daa.com.au
> http://www.daa.com.au/mailman/listinfo/pygtk
> Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.daa.com.au/pipermail/pygtk/attachments/20070616/e828c6c0/at=

More information about the pygtk mailing list