mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 02:15:43 -04:00
add wx-main-loop
This commit is contained in:
parent
401da63c22
commit
fb71b744a9
@ -2736,17 +2736,38 @@ class ShowBase(DirectObject.DirectObject):
|
|||||||
# Create a new base.wxApp.
|
# Create a new base.wxApp.
|
||||||
self.wxApp = wx.PySimpleApp(redirect = False)
|
self.wxApp = wx.PySimpleApp(redirect = False)
|
||||||
|
|
||||||
# Set a timer to run the Panda frame 60 times per second.
|
if ConfigVariableBool('wx-main-loop', True):
|
||||||
self.wxTimer = wx.Timer(self.wxApp)
|
# Put wxPython in charge of the main loop. It really
|
||||||
self.wxTimer.Start(1000.0/60.0)
|
# seems to like this better; some features of wx don't
|
||||||
self.wxApp.Bind(wx.EVT_TIMER, self.__wxTimerCallback)
|
# 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.
|
# wx is now the main loop, not us any more.
|
||||||
self.run = self.wxRun
|
self.run = self.wxRun
|
||||||
self.taskMgr.run = self.wxRun
|
self.taskMgr.run = self.wxRun
|
||||||
__builtin__.run = self.wxRun
|
__builtin__.run = self.wxRun
|
||||||
if self.appRunner:
|
if self.appRunner:
|
||||||
self.appRunner.run = self.wxRun
|
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):
|
def __wxTimerCallback(self, event):
|
||||||
if Thread.getCurrentThread().getCurrentTask():
|
if Thread.getCurrentThread().getCurrentTask():
|
||||||
|
Loading…
x
Reference in New Issue
Block a user