Put panda3d in a Class ready to be called in tkinter paned window

im trying to put the code in a class, so i can call it inside a paned window.
here is some code i have already.

from direct.showbase.ShowBase import ShowBase
from panda3d.core import WindowProperties
import tkinter


class panda():

    def initgl(self):
        # Start ShowBase, but don't open a Panda window yet
        base = ShowBase(windowType='none')

        # Start Tkinter integration, get the root window handle
        base.startTk()

        frame = base.tkRoot
        frame.update()
        id = frame.winfo_id()
        width = frame.winfo_width()
        height = frame.winfo_height()

        props = WindowProperties()
        props.setParentWindow(id)
        props.setOrigin(0, 0)
        props.setSize(width, height)

        base.makeDefaultPipe()
        base.openDefaultWindow(props=props)

        scene = base.loader.loadModel("environment")
        scene.reparentTo(base.render)

        base.run()

app = panda()

this is what im trying to achieve

Here is an example that creates a similar one, however you need to configure resizing and everything else. I’m not a Tk expert.

from direct.showbase.ShowBase import ShowBase
from panda3d.core import WindowProperties
import tkinter

class Tkinter_window(ShowBase):
  def __init__(self):
    ShowBase.__init__(self, windowType='none')
    
    root = tkinter.Tk()

    frame_panda3d = tkinter.Frame(root)
    frame_panda3d.place(x = 0, y = 0, height = 300, width = 400)
    
    frame_panel = tkinter.Frame(root, bg='blue')
    frame_panel.place(x = 400, y = 0, height = 300, width = 200)
   
    root.update()

    props = WindowProperties()
    props.setParentWindow(frame_panda3d.winfo_id())
    props.setOrigin(0, 0)
    props.setSize(frame_panda3d.winfo_width(), frame_panda3d.winfo_height())

    self.makeDefaultPipe()
    self.openDefaultWindow(props=props)

    scene = self.loader.loadModel("environment")
    scene.reparentTo(render)
    
tkinter_window = Tkinter_window()
tkinter_window.run()

i tried this:

self.app = Tkinter_window(m1)

but it wont let me append it to a paned window.

TypeError: __init__() takes 1 positional argument but 2 were given

maybe i can ask a expert on reddit.

To be honest, I don’t understand why your idea should work, I don’t even understand what your idea is.

do you know what paned window is? if not i’ll explain.

A paned window, this in other frameworks is name a splitter window. But whatever it is name, it does not depend on the panda, you decide how the widgets will be nested. You have a fully working example with frames, how, where, why, you put it, it’s just your decision.

ok, i’ll ask someone on reddit. here’s the code if you are interested.

import time
import tkinter
from tkinter import *

from direct.showbase.ShowBase import ShowBase
from panda3d.core import WindowProperties

class Tkinter_window(ShowBase):
  def __init__(self):
    ShowBase.__init__(self, windowType='none')
    base.startTk()
    
    frame = base.tkRoot
    frame.update()
    
    props = WindowProperties()
    props.setParentWindow(frame.winfo_id())
    props.setOrigin(0, 0)
    props.setSize(frame.winfo_width(), frame.winfo_height())

    base.makeDefaultPipe()
    base.openDefaultWindow(props=props)

    scene = base.loader.loadModel("environment")
    scene.reparentTo(render)
    
class main():
    def __init__(self, master):

        self.runv = True 

        m1 = PanedWindow(relief=RAISED, sashrelief=RAISED)
        m1.pack(fill=BOTH, expand=1)

        frame1 = Frame(m1, bg="#3a3b3d")

        menubutton = Menubutton(frame1, text = "File", bg="#3a3b3d", fg="#ffffff", activebackground="#3a3b3d")    
            
        menubutton.menu = Menu(menubutton)   
        menubutton["menu"]= menubutton.menu   
        
        var1 = IntVar() 
        var2 = IntVar() 
        var3 = IntVar() 
        
        menubutton.menu.add_checkbutton(label = "New", 
                                        variable = var1)   
        open_file_button = menubutton.menu.add_checkbutton(label = "Open", 
                                        variable = var2) 
        menubutton.menu.add_checkbutton(label = "Save", 
                                        variable = var3) 
            
        menubutton.pack(anchor="nw")  

        self.app = Tkinter_window(m1)
        m1.add(self.app)

        m1.add(frame1, width=400)
        self.right = Text(frame1, bg="#3a3b3d", fg="#ffffff", insertbackground='white')
        self.right.pack(fill=BOTH, expand=1)

        rightb = Button(frame1, text="run")
        rightb.pack()

if __name__ == '__main__':
    root = tkinter.Tk()
    root.title("Shaun Engine")
    app = main(root)
    root.mainloop()