From: Gary P. <pa...@in...> - 2004-04-29 12:28:59
|
I'm interested in what you are trying to do. Could you please post a minimal complete vpython/gtk script ... maybe one that just places a sphere at the origin. Thanks, gary ----- Original Message ----- From: "James Philip Roper" <u32...@an...> To: <vis...@li...> Sent: Monday, April 26, 2004 10:05 PM Subject: [Visualpython-users] Re: VPython / python-gtk integration > I have successfully run a simulation in VPython that had a pygtk > interface using threads. The main thread thread ran the GTK main loop, > then I had a thread for the simulation. I had issues quitting the > program (though I often also have the same issues when I'm not using > threading or pygtk), and there also seemed to be various quirks when I > tried running it on other platforms. This is the basic idea: > > import threading > > class simulator(threading.Thread): > def __init__(self): > threading.Thread.__init__(self) > self.runningEvent = threading.Event() > def run(self): > while 1: > self.runningEvent.wait() > # simulation stuff > > def startStopCallback(widget, data): > if s.runningEvent.isSet(): > s.runningEvent.clear() > else: > s.runningEvent.set() > > gtk.threads_init() > # gtk setup stuff including a start/stop button > > s = simulator() > s.start() > > > The gtk.threads_init() must be called if you are using pygtk and threading. > > One thing that you need to ensure, if you are ever making GTK calls from > a thread other than the thread GTK is running in, you must use > gtk.threads_enter() and gtk.threads_leave() before and after you make > the call. |