#!/usr/bin/env python
+
"""
Run wxPython in a second thread.
When using wxPython, the call to app.Mainloop() takes over
the thread from which it is called. This presents a
problem for applications that want to use the standard
- Python command line user interface, while occasionaly
+ Python command line user interface, while occasionally
creating a GUI window for viewing an image, plot, etc.
- One soultion is to mangage the GUI in a second thread.
+ One solution is to manage the GUI in a second thread.
wxPython does not behave well if windows are created in
a thread other than the one where wxPython was originally
def start(self):
""" start the GUI thread
"""
- import thread,time
+ import time
+ import thread
thread.start_new_thread(self.run, ())
def run(self):
the import would occur in the main thread and
wxPython wouldn't run correctly in the second thread.
"""
- from viewer_basics import *
+ import viewer_basics
+
try:
- self.app = SecondThreadApp(0)
+ self.app = viewer_basics.SecondThreadApp(0)
self.app.MainLoop()
except TypeError:
self.app = None
send an event to the catcher window in the
other thread and tell it to create a cone window.
"""
- import viewer_basics
+ import viewer_basics
+
if self.app:
evt = viewer_basics.AddCone()
viewer_basics.wxPostEvent(self.app.catcher, evt)