Do you need to do anything special to get direct-gui-edit to work? It doesn’t seem to work with this code. I can’t drag or resize the button.
from panda3d.core import *
from direct.fsm.FSM import FSM
from direct.gui.DirectGui import *
loadPrcFileData("", "direct-gui-edit 1")
class MainMenu(FSM):
def __init__(self, appCallback):
FSM.__init__(self, "MainMenu")
self.appCallback = appCallback
def enterMain(self):
self.button = DirectButton(text="Quit", command=self.quit, scale=0.05)
def exitMain(self):
print "exit called"
self.button.destroy()
def quit(self):
print "quit clicked"
self.appCallback("quit")
if __name__=="__main__":
from direct.showbase.ShowBase import ShowBase
import sys
class myapp(ShowBase):
def __init__(self):
ShowBase.__init__(self)
self.mainMenu = MainMenu(self.callback)
self.mainMenu.request("Main")
def callback(self, request):
if request == "quit":
self.mainMenu.cleanup()
sys.exit()
app = myapp()
app.run()