Forgive me I probably have to look into your code in greater detail. I wanted to start with a small scale test to figure things out so I made the following.
#### wx
from wxPython.wx import *
#### panda3d
from pandac.PandaModules import *
import direct.directbase.DirectStart
from direct.showbase.ShowBase import ShowBase #no handy goodies
from direct.showbase.DirectObject import DirectObject #handy goodies
from direct.task import Task
#### other
from math import pi, sin, cos
import sys
ID_ABOUT = 101
ID_EXIT = 102
class ParentFrame(wxMDIParentFrame):
def __init__(self, parent, ID, title):
wxFrame.__init__(self, parent, ID, title,
wxDefaultPosition, wxSize(800, 600))
self.CreateStatusBar()
self.SetStatusText("This is the statusbar")
menu = wxMenu()
menu.Append(ID_ABOUT, "&About",
"More information about this program")
menu.AppendSeparator()
menu.Append(ID_EXIT, "E&xit", "Terminate the program")
menuBar = wxMenuBar()
menuBar.Append(menu, "&File");
self.SetMenuBar(menuBar)
class ChildFrame(wxMDIChildFrame):
def __init__(self, parent, ID, title):
wxFrame.__init__(self, parent, ID, title,
wxDefaultPosition, wxSize(200, 150))
self.CreateStatusBar()
self.SetStatusText("This is the statusbar")
menu = wxMenu()
menu.Append(ID_ABOUT, "&About",
"More information about this program")
menu.AppendSeparator()
menu.Append(ID_EXIT, "E&xit", "Terminate the program")
menuBar = wxMenuBar()
menuBar.Append(menu, "&File");
self.SetMenuBar(menuBar)
class AppType(wxPySimpleApp, DirectObject):
def __init__(self):
wxPySimpleApp.__init__(self)
print "Application Initializing. Hold on to your butts."
###shortcuts
self.loader = loader
self.taskMgr = taskMgr
self.camera = base.camera
#Create a new event loop (to overide default wxEventLoop)
self.evtloop = wxEventLoop()
self.old = wxEventLoop.GetActive()
wxEventLoop.SetActive(self.evtloop)
taskMgr.add(self.wx,"Custom wx Event Loop")
# wxWindows calls this method to initialize the application
# wxWindows calls this method to initialize the application
def OnInit(self):
self.SetAppName('My wx app')
self.SetClassName('MyAppClass')
self.SetAppName('Editor')
self.SetClassName('MyAppClass')
self.parent = ParentFrame(None, -1, 'super cool app')
self.child = ChildFrame(self.parent, -1, 'Panda3D')
#Main Window
self.parent.SetClientSize((800, 600))
self.parent.Show(True)
#self.parent.ShowFullScreen(True)
#Child Window
self.child.SetClientSize((200, 150))
self.child.Show(True)
base.windowType = 'onscreen'
props = WindowProperties.getDefault()
#props.setParentWindow(self.child.GetHandle())
props.setParentWindow(self.parent.GetHandle())
props.setOrigin(0,0)
base.openDefaultWindow(props = props)
base.setFrameRateMeter(True)
self.child.SetFocus()
return True
def wx(self,task):
while self.evtloop.Pending():
self.evtloop.Dispatch()
#Thread.sleep(0.01)
self.ProcessIdle()
return Task.cont
def close(self):
wxEventLoop.SetActive(self.old)
self.parent.Bind(wx.EVT_CLOSE,sys.exit)
def run(self):
run()
p3dApp = AppType()
# Load the environment model.
environ = p3dApp.loader.loadModel("models/environment")
# Reparent the model to render.
environ.reparentTo(render)
# Apply scale and position transforms on the model.
environ.setScale(0.25, 0.25, 0.25)
environ.setPos(-8, 42, 0)
# Define a procedure to move the camera.
def spinCameraTask(task):
angleDegrees = task.time * 6.0
angleRadians = angleDegrees * (pi / 180.0)
p3dApp.camera.setPos(20 * sin(angleRadians), -20.0 * cos(angleRadians), 3)
p3dApp.camera.setHpr(angleDegrees, 0, 0)
return Task.cont
# Add the procedure to the task manager.
p3dApp.taskMgr.add(spinCameraTask, "SpinCameraTask")
# Run the engine.
p3dApp.run()
It doesn’t work very well as you can see.