PyDeadObjectError when deleting a panel with auitoolbar via the toolbar

101 Views Asked by At

I have a panel with auitoolbar in it and a 'delete' button on the toolbar. Pressing this button will delete the panel and everything in it. The problem is that beside wx.EVT_TOOL which I use to trigger the deletion, auitoolbar also triggers OnLeftUp event which happens after the panel was deleted, thus the PyDeadObjectError. Is there any way around this? Regular button works just fine, it's just a problem with auitoolbar.

python 2.7.2
wxpython 2.8.12
1

There are 1 best solutions below

3
On

Is OnLeftUp bound with wx.EVT_LEFT_UP event? If so, then on panel deletion you need also to explicitly unbind your panel with the event:

self.panel.Unbind(wx.EVT_LEFT_UP)