Hi!
I have been working around an issue I have with Panda3D task manager. In my App I’m using Panda3D and wxPython. I want Panda3D own the main task so I call Showbase.run() and I add a task to execute my code.
This works good! But I have realized that if I click with the mouse on a wxPython Menu, the windows frame or I move the frame… the task is not called during the time the mouse button is down or the menu open. I have been testing a little bit and using wxPython to call my task seems to work fine… Can someone help me telling me what I’m doing wrong?
(This code shows the issue, and it is possible to test both situations changing usePanda3D = True/False)
Thanks!
from direct.showbase.ShowBase import ShowBase
import wx
import time
class MyApp():
def __init__(self):
print time.clock(),"Simumatic3D Created"
def mainLoop(self, task=None):
print time.clock(),"MainLoop"
if task:
return task.cont
else:
wx.CallLater(10, self.mainLoop)
class Panda3DWorld(ShowBase):
def __init__(self):
print time.clock(),"Panda3DWorld Created"
ShowBase.__init__(self)
class wxWorld(wx.App):
def __init__(self):
print time.clock(),"wxWorld Created"
wx.App.__init__(self,False)
frame = wx.Frame(None, wx.ID_ANY, "Hello World")
# Menu Bar
menubar = wx.MenuBar()
filemenu= wx.Menu()
filemenu.Append(wx.ID_ANY,"New")
menubar.Append(filemenu, "File")
frame.SetMenuBar(menubar)
frame.Show(True)
app = MyApp()
gui = wxWorld()
graphics = Panda3DWorld()
# Test
usePanda3D = True
if (usePanda3D):
graphics.taskMgr.add(app.mainLoop, "mainloop")
else:
app.mainLoop()
graphics.run()