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,6 +2736,11 @@ class ShowBase(DirectObject.DirectObject):
# Create a new base.wxApp.
self.wxApp = wx.PySimpleApp(redirect = False)
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)
@ -2748,6 +2753,22 @@ class ShowBase(DirectObject.DirectObject):
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():
# This happens when the wxTimer expires while igLoop is