Error when trying to loop Panda window

My Panda class is currently being instantiated and run from a GUI window (PySimpleGUI) and I’m trying make it so that when I close the Panda window it continues on with the main program loop (i.e. keeps the GUI window open) instead of killing the Python interpreter along with it.

I’ve very simply overidden the finalizeExit method as follows:

def finalizeExit(self):
        self.destroy()

But I’m getting this error (Environment being my ShowBase inherited class):

File “C:\Panda3D-1.10.11-x64\direct\showbase\ShowBase.py”, line 1362, in getAspectRatio
win = self.win
AttributeError: ‘Environment’ object has no attribute ‘win’

Not sure how to fix it, any help appreciated

I think it would be more correct to create an instance of ShowBase without a window. And by the way, if you close the window programmatically, then python will remain working.

#from panda3d.core import loadPrcFileData 
#loadPrcFileData("", "window-type none")

from direct.showbase.ShowBase import ShowBase

class MyApp(ShowBase):
    def __init__(self):
        ShowBase.__init__(self)

        base.closeWindow(base.win)

app = MyApp()
app.run()

Thanks, if I include the closeWindow() in my exit method, it closes the window alright, but I still can’t access my GUI (as in Python is still waiting on Panda to close I guess). If I create a keyboard interrup with Ctrl+C then I can use the GUI again.

Is there anything else I’m missing?

Thanks

You don’t have to use a panda loop, you need to call a callback from your own GUI every time it is idle. Next, just call the step() method for the task manager.

Oooh I see, thanks so much for your help