Added support for wxPython

This commit is contained in:
Gyedo Jeon 2008-04-21 19:14:52 +00:00
parent 894493de24
commit 0268785c91
2 changed files with 28 additions and 3 deletions

View File

@ -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
View 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")