0

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
hdrz
  • 461
  • 6
  • 12

1 Answers1

0

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) 
Andrey Sobolev
  • 12,353
  • 3
  • 48
  • 52
  • I guess it is, but it is something internal in auitoolbar, and I can't unbind it no matter what I do. – hdrz Jan 29 '13 at 09:32
  • Then, if you can't just unbind the `LEFT_UP` event from auitoolbar before panel deletion, you can subclass the `AuiToolBar` class, bind some method with `EVT_CLOSE`, and in that method unbind the `LEFT_UP` event. – Andrey Sobolev Jan 29 '13 at 09:57
  • After a bit of digging, it seems that all the functionality of a button press & release is handled in auitoolbar by `wx.EVT_LEFT_UP`, so maybe the only option is to use the same event for triggering the deletion. – hdrz Jan 29 '13 at 13:03