Hello. This post might not be the first on this topic. However, I still want to make it to further clarify on this.
I am using Panda3d on MacOS, and I want to embed it on tkinter frame so that my application would have a 3d viewport.
I am trying out this code:
from direct.showbase.ShowBase import ShowBase
from panda3d.core import WindowProperties
from tkinter import Button, CENTER
class AppTk(ShowBase):
def __init__(self):
ShowBase.__init__(self, windowType = 'none')
base.startTk()
self.frame = base.tkRoot
self.frame.geometry("800x600")
button = Button(self.frame, text = 'Click me !', bd = '5', command = self.test)
#button.pack(side = 'top')
button.place(x = 400, y = 300, anchor = CENTER)
props = WindowProperties()
props.set_parent_window(self.frame.winfo_id())
props.set_origin(0, 0)
props.set_size(self.frame.winfo_width(), self.frame.winfo_height())
base.make_default_pipe()
base.open_default_window(props = props)
self.frame.bind("<Configure>", self.resize)
scene = loader.load_model("environment")
scene.reparent_to(render)
def test(self):
print("Hello")
def resize(self, event):
props = WindowProperties()
props.set_origin(0, 0)
props.set_size(self.frame.winfo_width(), self.frame.winfo_height())
base.win.request_properties(props)
app = AppTk()
app.run()
However, on mac, it segmentation faults.
I tried to remove certain pieces of code and it works when I remove props.set_parent_window
, but the window is not embedded on the tkinter window. Furthermore, the window does not respond when I press the “Click me” button.
I have not tried this on windows as I own a mac, but according to other posts, it seems to work on windows but not on mac.
Is there any solution or alternative to this so that it works on mac?