I've never had any luck with all the GTK code in a thread. But using this tip from the FAQ
http://faq.pygtk.org/index.py?req=show&file=faq20.001.htp worked fine on your example code. On May 14, 2010, at 1:48 PM, Neil Benn wrote: > Hello, > > I have a very simple question which is stumping me. I want to start > up PyGTK and then do some interaction with my business layer to do the work I > need so that I can display the data on my PyGTK app. I'm setting up a window > and then calling gtk.main(). However when I do that everything else freezes; > I'm starting up an app and running something on a separate thread in the > background by gtk.main just stops running. I've recreated the problem in a > simple use case below which is: > > <code> > import pygtk > pygtk.require('2.0') > import gtk > import time > from threading import Thread > > class W(Thread): > def __init__(self): > Thread.__init__(self) > self.window = gtk.Window() > > def run(self): > self.window.show() > gtk.main() > > class A(Thread): > def __init__(self): > Thread.__init__(self) > self.count = 0 > > def run(self): > while True: > print 'a', self.count > self.count += 1 > > class B(Thread): > def __init__(self): > Thread.__init__(self) > self.count = 0 > > def run(self): > while True: > print 'b', self.count > self.count += 1 > > if __name__ == '__main__': > a = A() > b = B() > w = W() > a.start() > b.start() > time.sleep(2) > w.start() > while True: > time.sleep(0.1) > </code> > > This starts up as you would expect, printing a and b to the screen as the > threading time time slicing allows. However once the PyGTK window has opened > - these threads just freeze. I'm sure I cannot be the only person who deals > with this and it seems crazy to try and run everything on the GTK thread as > it would surely make the GUI unresponsive on operations which take a long > time? > > Note that I cannot trigger the app's business layer to start processing on > a button click as the app needs to interact with the business layer (a camera > capturing frames) from the word go and the application screen must be very > simple with no buttons to click at all (it is just used to report the output > from the camera after some frame processing). > > Thanks, in advance for your help. > > Cheers, > > Neil > > -- > -- > > Neil Benn Msc > Director > Ziath Ltd > Phone :+44 (0)7508 107942 > Website - http://www.ziath.com > > IMPORTANT NOTICE: This message, including any attached documents, is > intended only for the use of the individual or entity to which it is > addressed, and may contain information that is privileged, confidential and > exempt from disclosure under applicable law. If the reader of this message > is not the intended recipient, or the employee or agent responsible for > delivering the message to the intended recipient, you are hereby notified > that any dissemination, distribution or copying of this communication is > strictly prohibited. If you have received this communication in error, please > notify Ziath Ltd immediately by email at i...@ziath.com. Thank you. > _______________________________________________ > pygtk mailing list pygtk@daa.com.au > http://www.daa.com.au/mailman/listinfo/pygtk > Read the PyGTK FAQ: http://faq.pygtk.org/ -- Steve McClure smccl...@racemi.com
_______________________________________________ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://faq.pygtk.org/