mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-02 09:52:27 -04:00
add wx-main-loop
This commit is contained in:
parent
401da63c22
commit
fb71b744a9
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user