Sebastian "Marduk" Pölsterl wrote:

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

nephish schrieb:
OK
i looked at the docs in the link.
does this mean i set up every thread (i need to run four) as its own
subclass of threading.thread?
and call it like that?
Exactly.
You write your class:
class MyThread(threading.Thread):
        def __init__(self):
                threading.Thread.__init__(self)
        def run(self):
                # Your process running as thread

and then call:
mythread = MyThread()
mythread.start()

with mythread.isAlive() you can check if your thread is finished

the examples i have seen so far just set it as a function and then call
the function with threading.Thread.start(function())
maybe i am missing something in the terminology.
thanks for the reply by the way.

I only know this procedure from Thread.start_new_thread()
See http://docs.python.org/lib/module-thread.html for more detail.

- --
Greetings,
Sebastian Pölsterl
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFDHxNq1ygZeJ3lLIcRAtwHAKCQWVFP9rhyhA/8HBQo8k2REcEvAgCeOFn0
ue3aHcmBvP54QeA0orim3Hg=
=Wd6V
-----END PGP SIGNATURE-----
_______________________________________________
pygtk mailing list   [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/

Getting closer.

ok, iv'd done what you posted and it works.
the gui does not hang, the files are written in the background, and
it looks good.
the only obstacle left is getting the output to the text view.

the info is from two different classes.

class Serial1(threading.Thread):
   def __init__(self, buffer):
       threading.Thread.__init__(self)
       print 'running serial 1'
def run(self):
           ser = serial.Serial('/dev/ttyS15', 2400, timeout=None)
           loopy = 1
           i = 1
while loopy < 5: for x in range(5): get a bunch of serial info x_Now = strftime('%Y-%m-%d %print 'bout to do thread stuff' Input1Data = str(Sensor_ID)+'\t'+str(Status)+'\t--------->\t'+x_Now+'\n' gobject.idle_add(self.buffer_add, buffer, Input1Data) def buffer_add(self, buffer, Input1Data):
       Iter = buffer.get_end_iter()
       buffer.insert(Input1Iter, Input1Data)

class Main(SimpleGladeApp):
   def __init__(self, path="pivcontrolcenter.glade",
                root="Main",
                domain=app_name, **kwargs):

def on_StartEnginesButton_clicked(self, widget, *args): Input1Iter = self.Input1Buffer.get_end_iter() Input1Data = 'Reading Serial device ttyS14 \n' self.Input1Buffer.insert(Input1Iter, Input1Data) time.sleep(1)
       S1 = Serial1(buffer)
       S1.start()

in this, when the button is clicked. the first part is written to the text view. then the thread is started. but i cant seem to get the attributes from Main()
to Serial1().
i just need to be able to pass the textview buffer to the serial class so it can be written to .
the above code is my best guess so far.
can you see where i am missing it here?

thanks
_______________________________________________
pygtk mailing list   [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/

Reply via email to