I'm writing an application with a wx.treectrl on the left and a panel on the right. Every item selection destroys a panel on the right and adds a new one. Until wxPython 2.8.8.1 all was fine, but with the new 2.8.9.1 version, my application crashes without any feedback while calling the panels Destroy() method.
I wish i could give you an example of this, but I'm not able to write a less complex application, that reproduces this behaviour, so i can't show you.
Has anybody an idea of what I'm doing wrong?
def OnSelChanged(self, event = None):
item = event.GetItem()
if not item.IsOk():
return #Delete old panel
for i in self.parent.propertiesPanel.GetChildren():
if i.GetName() == "propertyPanel":
i.Destroy()
I’m writing an application with a wx.treectrl on the left and a panel on the right. Every item selection destroys a panel on the right and adds a new one. Until wxPython 2.8.8.1 all was fine, but with the new 2.8.9.1 version, my application crashes without any feedback while calling the panels Destroy() method.
I wish i could give you an example of this, but I’m not able to write a less complex application, that reproduces this behaviour, so i can’t show you.
Has anybody an idea of what I’m doing wrong?
def OnSelChanged(self, event = None):
item = event.GetItem()
if not item.IsOk():
return
#Delete old panel
for i in self.parent.propertiesPanel.GetChildren():
if i.GetName() == "propertyPanel":
i.Destroy()
cu alex
Could you add some debugging print statements to see how far it gets? How many times it calls Destroy()?
Destroy can only be called once per object; perhaps there’s an object which is somehow being destroyed more than once?
Is there a way to have the property-panel(s) attributes of your class, so that you don’t have to loop through the children of the parent panel?
Perhaps you could add an attribute to each property-panel which you create, a flag that tells you if the panel is already destroyed and then not destroy it again?
Just some more-or-less random ideas which have helped me in my applications, although it doesn’t really sound like any of these is directly related to your problem (since your application worked well before).
I'm writing an application with a wx.treectrl on the left and a panel on the right. Every item selection destroys a panel on the right and adds a new one. Until wxPython 2.8.8.1 all was fine, but with the new 2.8.9.1 version, my application crashes without any feedback while calling the panels Destroy() method.
I wish i could give you an example of this, but I'm not able to write a less complex application, that reproduces this behaviour, so i can't show you.
Has anybody an idea of what I'm doing wrong?
def OnSelChanged(self, event = None):
item = event.GetItem()
if not item.IsOk():
return #Delete old panel
for i in self.parent.propertiesPanel.GetChildren():
if i.GetName() == "propertyPanel":
i.Destroy()
In addition to Tim's suggestions I would suggest trying to delay the destroy until you are sure that there are no pending events for the panel. You can do that with something like this:
i.Hide()
wx.CallAfter(i.Destroy)
···
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!