add wx-main-loop

This commit is contained in:
David Rose 2012-01-16 01:56:48 +00:00
parent 401da63c22
commit fb71b744a9

View File

@ -2736,17 +2736,38 @@ class ShowBase(DirectObject.DirectObject):
# Create a new base.wxApp.
self.wxApp = wx.PySimpleApp(redirect = False)
# Set a timer to run the Panda frame 60 times per second.
self.wxTimer = wx.Timer(self.wxApp)
self.wxTimer.Start(1000.0/60.0)
self.wxApp.Bind(wx.EVT_TIMER, self.__wxTimerCallback)
if ConfigVariableBool('wx-main-loop', True):
# Put wxPython in charge of the main loop. It really
# seems to like this better; some features of wx don't
# work properly unless this is true.
# Set a timer to run the Panda frame 60 times per second.
self.wxTimer = wx.Timer(self.wxApp)
self.wxTimer.Start(1000.0/60.0)
self.wxApp.Bind(wx.EVT_TIMER, self.__wxTimerCallback)
# wx is now the main loop, not us any more.
self.run = self.wxRun
self.taskMgr.run = self.wxRun
__builtin__.run = self.wxRun
if self.appRunner:
self.appRunner.run = self.wxRun
# wx is now the main loop, not us any more.
self.run = self.wxRun
self.taskMgr.run = self.wxRun
__builtin__.run = self.wxRun
if self.appRunner:
self.appRunner.run = self.wxRun
else:
# Leave Panda in charge of the main loop. This is
# friendlier for IDE's and interactive editing in general.
def wxLoop(task):
# First we need to ensure that the OS message queue is
# processed.
base.wxApp.Yield()
# Now do all the wxPython events waiting on this frame.
while base.wxApp.Pending():
base.wxApp.Dispatch()
return task.again
taskMgr.add(wxLoop, 'wxLoop')
def __wxTimerCallback(self, event):
if Thread.getCurrentThread().getCurrentTask():