Just want to chime in here and say that you can use imgui (pyimgui) as well.
from direct.showbase.ShowBase import ShowBase
from direct.task import Task
from direct.showbase.DirectObject import DirectObject
import imgui
from imgui.integrations.opengl import ProgrammablePipelineRenderer as ImguiRenderer
class imguiApp(ShowBase):
def __init__(self):
ShowBase.__init__(self)
imgui.create_context()
imgui.get_io().display_size = self.get_size()
imgui.get_io().fonts.get_tex_data_as_rgba32()
self.imgui_renderer = ImguiRenderer()
self.accept("mouse1", self.mouse_down)
self.accept("mouse1-up", self.mouse_up)
self.mouse_down = False
self.taskMgr.add(self.imgui, "gui")
def imgui(self, task):
x, y = self.win.get_pointer(0).get_x(), self.win.get_pointer(0).get_y()
imgui.get_io().mouse_pos = x, y
imgui.get_io().mouse_down[0] = self.mouse_down
imgui.new_frame()
imgui.begin("Start Window", True)
imgui.text("Basic imgui Window")
imgui.button("Click Here")
imgui.end()
imgui.render()
imgui.end_frame()
self.imgui_renderer.render(imgui.get_draw_data())
return Task.cont
def mouse_down(self):
self.mouse_down = True
def mouse_up(self):
self.mouse_down = False
app = imguiApp()
app.run()
https://pyimgui.readthedocs.io/en/latest/guide/first-steps.html