I am developing a GUI with wxPython. I draw a square which represents a CD object, inside another square (also with wxPanel class), which represents CD Container Object.
I want to have “delete this CD” in the right click menu of CDWindow, which will remove the CDwindow.
Basically, my code looks like this (for simplicity, I keep the main parts):
class CDContainerWindow(wx.Panel):
def __init__(self):
wx.Panel.__init__(self, parent, id, pos, size)
cd_win=CDWindow()
class CDWindow(wx.Panel):
def __init__(self):
wx.Panel.__init__(self, parent, id, pos, size)
self.Bind(wx.EVT_MENU, self.OnDeleteCD, item_CD)
def OnDeleteCD(self, event):
self.destroy()
There is an error message “Segmentation fault”
What is wrong with my way? How can I delete this CD window from the CDContainer Window?
Maybe there’s a sizer still using the destroyed panel? You should remove the panel from the sizer first.