import sys from pathlib import Path lui_path = Path(__file__).parent.parent.absolute() builtin_path = lui_path / "Builtin" sys.path.insert(0, str(lui_path)) sys.path.insert(0, str(builtin_path)) import panda3d.core import lui import panda3d panda3d.lui = lui sys.modules["panda3d.lui"] = lui # Load some builtin LUI classes. When lui is included in panda, this will be # from direct.lui.LUIButton import LUIButton from Builtin.LUIButton import LUIButton from Builtin.LUISkin import LUIDefaultSkin from Builtin.LUIRegion import LUIRegion from Builtin.LUIInputHandler import LUIInputHandler # Setup panda, nothing special here from panda3d.core import load_prc_file_data load_prc_file_data("", """ text-minfilter linear text-magfilter linear text-pixels-per-unit 32 sync-video #f textures-power-2 none show-frame-rate-meter #t win-size 700 600 window-title LUI Minimal Example """) from direct.showbase.ShowBase import ShowBase class Application(ShowBase): def __init__(self): ShowBase.__init__(self) # Construct a new LUIRegion region = LUIRegion.make("LUI", base.win) # Construct a new InputHandler to catch and process events handler = LUIInputHandler() base.mouseWatcher.attach_new_node(handler) region.set_input_handler(handler) # Load the default LUI skin skin = LUIDefaultSkin() skin.load() # LUI is initialized now, so we can start adding elements, for example: button = LUIButton(parent=region.root, text="Hello world!", top=30, left=30) Application().run()