I recently decided to write my first app with Python and PySide. But I have a problem and hope you guys can help.
Python keeps raising exceptions that the "Internal C++ Object" is deleted. From my limited experience with Python I figure that my object is going out of scope and being deleted by Python's Garbage Collector.
So how would I go about designing a multi-page application in Python with PySide. And being able to keep my QWidgets so I can show the page again.
Thanks for your time.
Update (Code)
instancing = None
def instance():
global instancing
if instancing == None:
instancing = WPZKernel()
return instancing
class WPZKernel:
win = None
mainscreen = None
def mainwindow(self):
if self.win == None:
self.win = GMKMainWindow(self)
return self.win
def main_panel(self):
if self.mainscreen == None:
self.mainscreen = GMKMainScreen(self.mainwindow())
return self.mainscreen
I would then normally access the mainpanel by calling:
import kernel
kernel.instance().main_panel()
So am I going about this the wrong way?
After some searching and hair pulling, I found the solution. I was showing all the pages by setting them as the central widget, and when reading the QMainWindow documentation I found that my widget basically gets deleted by qt as stated:
So to develop a Multi-Page application rather take a look at QStackedWidget.
See here: PySide Pitfalls.