#1
|
|||
|
|||
quit an embedded viz-simulation
hi there,
i was creating a frame with wxPython. from this frame i started an embedded viz-simulation. so far it works quite well. (i found everything i need here. thanks for that ) but if i try to close this simulation and start it again form the mainFrame, the new simulation is just gray. the problem is that i am not able to call the viz.quit() function to clean up. as you can see in the code i was testing the function calls by printouts. the viz.EXIT_EVENT is not executed before i close the wxPython mainFrame. my onKeyDown() function does the test print as it should be done, but it ignores the viz.quit() without an error. i hope you can help me. here is my code: #wxFrame class import viz import wx import ducks #this is my testsimulation class MainFrame(wx.Frame): def __init__(self, parent, id, title): wx.Frame.__init__(self, parent, id, title) #Menubar menubar = wx.MenuBar() worldViz = wx.Menu() ... worldViz.Append(104, '&Simulation', 'Start a 3D-simulation') self.SetMenuBar(menubar) wx.EVT_MENU(self, 104, self.onStart3D) ... def onStart3D(self, event): self.timer = wx.Timer(self, 5000) #timer to refresh the simulation self.timer.Start(10) wx.EVT_TIMER(self, 5000, self.onTimer) self.sim = viz.go(viz.EMBEDDED) test = ducks.simulation() def onTimer(self, event): viz.updateframe() #my testsimulation class import viz def simulation(): viz.clearcolor(0.5, 0.5, 1.0) #Set ViewPoint view = viz.MainView view.setPosition(0, 1, -20) #Turn on the physics engine viz.phys.enable() #Add ground ground = viz.add('tut_ground.wrl') ground.collidePlane() ... #Exit-function def onkeydown(key): #exit the simulation if you press 1 if key == '1': print 'test' viz.quit() viz.callback(viz.KEYDOWN_EVENT, onkeydown) def onexit(): print 'onexit executed' viz.quit() viz.callback(viz.EXIT_EVENT, onexit) #this is the starting class import wx from MainFrame import * class MainApp(wx.App): def OnInit(self): frame = MainFrame(None,-1, 'Phantom') frame.Show(True) return True app = MainApp(0) app.MainLoop() del app |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
vizard quit automatically in full screen stereo mode | fuyonggang | Vizard | 3 | 09-15-2008 09:51 AM |
closing files on a force quit | vadrian | Vizard | 1 | 02-14-2005 11:38 AM |
embedded Vizard | tavaksai | Vizard | 5 | 12-21-2004 07:49 AM |