X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/96d49f0eea53dbaae6fd926d6a2107f9f6e87e7d..f2ea42557b8570b18082542f043c26b9ba346d21:/wxPython/samples/mainloop/mainloop.py diff --git a/wxPython/samples/mainloop/mainloop.py b/wxPython/samples/mainloop/mainloop.py index 1074b83b3d..64a60a9648 100755 --- a/wxPython/samples/mainloop/mainloop.py +++ b/wxPython/samples/mainloop/mainloop.py @@ -67,44 +67,39 @@ class MyFrame(wx.Frame): class MyApp(wx.App): def MainLoop(self): - if "wxMac" in wx.PlatformInfo: - # TODO: Does wxMac implement wxEventLoop yet??? - wx.App.MainLoop() - - else: - # Create an event loop and make it active. If you are - # only going to temporarily have a nested event loop then - # you should get a reference to the old one and set it as - # the active event loop when you are done with this one... - evtloop = wx.EventLoop() - old = wx.EventLoop.GetActive() - wx.EventLoop.SetActive(evtloop) - - # This outer loop determines when to exit the application, - # for this example we let the main frame reset this flag - # when it closes. - while self.keepGoing: - # At this point in the outer loop you could do - # whatever you implemented your own MainLoop for. It - # should be quick and non-blocking, otherwise your GUI - # will freeze. - - # call_your_code_here() - - - # This inner loop will process any GUI events - # until there are no more waiting. - while evtloop.Pending(): - evtloop.Dispatch() - - # Send idle events to idle handlers. You may want to - # throttle this back a bit somehow so there is not too - # much CPU time spent in the idle handlers. For this - # example, I'll just snooze a little... - time.sleep(0.10) - self.ProcessIdle() - - wx.EventLoop.SetActive(old) + # Create an event loop and make it active. If you are + # only going to temporarily have a nested event loop then + # you should get a reference to the old one and set it as + # the active event loop when you are done with this one... + evtloop = wx.EventLoop() + old = wx.EventLoop.GetActive() + wx.EventLoop.SetActive(evtloop) + + # This outer loop determines when to exit the application, + # for this example we let the main frame reset this flag + # when it closes. + while self.keepGoing: + # At this point in the outer loop you could do + # whatever you implemented your own MainLoop for. It + # should be quick and non-blocking, otherwise your GUI + # will freeze. + + # call_your_code_here() + + + # This inner loop will process any GUI events + # until there are no more waiting. + while evtloop.Pending(): + evtloop.Dispatch() + + # Send idle events to idle handlers. You may want to + # throttle this back a bit somehow so there is not too + # much CPU time spent in the idle handlers. For this + # example, I'll just snooze a little... + time.sleep(0.10) + self.ProcessIdle() + + wx.EventLoop.SetActive(old)