X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/f6bcfd974ef26faf6f91a62cac09827e09463fd1..b4eecebd423df0c6efe86d7658cd3df818d67ed8:/wxPython/demo/viewer.py?ds=sidebyside diff --git a/wxPython/demo/viewer.py b/wxPython/demo/viewer.py index ad438e10a0..a0332d98cb 100644 --- a/wxPython/demo/viewer.py +++ b/wxPython/demo/viewer.py @@ -1,4 +1,5 @@ #!/usr/bin/env python + """ Run wxPython in a second thread. @@ -35,9 +36,9 @@ 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 @@ -56,7 +57,8 @@ class viewer_thread: def start(self): """ start the GUI thread """ - import thread,time + import time + import thread thread.start_new_thread(self.run, ()) def run(self): @@ -68,9 +70,10 @@ class viewer_thread: 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 @@ -80,7 +83,8 @@ class viewer_thread: 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)