mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-01 09:23:03 -04:00
Added support for wxPython
This commit is contained in:
parent
894493de24
commit
0268785c91
@ -2215,6 +2215,14 @@ class ShowBase(DirectObject.DirectObject):
|
||||
def finalizeExit(self):
|
||||
sys.exit()
|
||||
|
||||
# [gjeon] start wxPyhton
|
||||
def startWx(self, fWantWx = 1):
|
||||
self.wantWx = fWantWx
|
||||
if self.wantWx:
|
||||
import WxGlobal
|
||||
taskMgr.remove('wxLoop')
|
||||
WxGlobal.spawnWxLoop()
|
||||
|
||||
def startTk(self, fWantTk = 1):
|
||||
self.wantTk = fWantTk
|
||||
if self.wantTk:
|
||||
@ -2222,8 +2230,9 @@ class ShowBase(DirectObject.DirectObject):
|
||||
taskMgr.remove('tkLoop')
|
||||
TkGlobal.spawnTkLoop()
|
||||
|
||||
def startDirect(self, fWantDirect = 1, fWantTk = 1):
|
||||
def startDirect(self, fWantDirect = 1, fWantTk = 1, fWantWx = 0):
|
||||
self.startTk(fWantTk)
|
||||
self.startWx(fWantWx)
|
||||
self.wantDirect = fWantDirect
|
||||
if self.wantDirect:
|
||||
from direct.directtools import DirectSession
|
||||
@ -2236,13 +2245,14 @@ class ShowBase(DirectObject.DirectObject):
|
||||
return
|
||||
self.__directStarted = False
|
||||
|
||||
# Start Tk and DIRECT if specified by Config.prc
|
||||
# Start Tk, Wx and DIRECT if specified by Config.prc
|
||||
fTk = self.config.GetBool('want-tk', 0)
|
||||
fWx = self.config.GetBool('want-wx', 0)
|
||||
# Start DIRECT if specified in Config.prc or in cluster mode
|
||||
fDirect = (self.config.GetBool('want-directtools', 0) or
|
||||
(self.config.GetString("cluster-mode", '') != ''))
|
||||
# Set fWantTk to 0 to avoid starting Tk with this call
|
||||
self.startDirect(fWantDirect = fDirect, fWantTk = fTk)
|
||||
self.startDirect(fWantDirect = fDirect, fWantTk = fTk, fWantWx = fWx)
|
||||
|
||||
def profileFrames(self, num=1):
|
||||
# profile the next 'num' frames and log the results
|
||||
|
15
direct/src/showbase/WxGlobal.py
Executable file
15
direct/src/showbase/WxGlobal.py
Executable file
@ -0,0 +1,15 @@
|
||||
import wx
|
||||
from direct.task.Task import Task
|
||||
|
||||
def wxLoop(self):
|
||||
# Do all the wxPython events waiting on this frame
|
||||
while base.wxApp.Pending():
|
||||
base.wxApp.Dispatch()
|
||||
return Task.cont
|
||||
|
||||
def spawnWxLoop():
|
||||
if hasattr(base, 'wxApp') and base.wxApp:
|
||||
base.wxApp.Exit()
|
||||
base.wxApp = wx.App(False)
|
||||
# Spawn this task
|
||||
taskMgr.add(wxLoop, "wxLoop")
|
Loading…
x
Reference in New Issue
Block a user