Hello,
I am making Yet Another Text Editor, using wx.stc. I have a bunch of
editor windows inside an aui.Notebook, and I want to perform cleanup
when a tab is closed. I can detect a closing tab by hooking to
wx.EVT_AUINOTEBOOK_PAGE_CLOSE,
but it seems that there is no equivalent for the stc itself.
I would expect that handling EVT_CLOSE would do it, but it seems that
it's only fired for frames and dialogs.
Right now I have:
def OnPageClose(self, event):
ed = self._nb.GetPage(event.Selection)
self.windows.remove(ed)
ed.Close()
event.Skip()
And in my stc subclass
def Close(self):
if self._buffer is not None:
self.UnhookBuffer(self._buffer)
This works, but feels a bit dirty. I couldn't find any way of
detecting when the editor goes away so I can unhook from my listeners
then. I'm sure I'm missing something, this would surely be a common
thing.
Thanks very much,
Orestis Markou
···
--
orestis@orestis.gr
http://orestis.gr
Hm, if I try to access the editor after it's being closed, I get a
DeadObject exception, so I presume that something is destroyed. I
guess overriding __del__ makes sense in a general Python sense.
Thanks, I'll try that!
···
On Thu, Dec 11, 2008 at 7:10 PM, Cody Precord <codyprecord@gmail.com> wrote:
Hello,
On Thu, Dec 11, 2008 at 12:59 PM, Orestis Markou <orestis@orestis.gr> wrote:
Hello,
I am making Yet Another Text Editor, using wx.stc. I have a bunch of
editor windows inside an aui.Notebook, and I want to perform cleanup
when a tab is closed. I can detect a closing tab by hooking to
wx.EVT_AUINOTEBOOK_PAGE_CLOSE,
but it seems that there is no equivalent for the stc itself.
I would expect that handling EVT_CLOSE would do it, but it seems that
it's only fired for frames and dialogs.
Because you are not really closing anything, an object is being deleted.
EVT_WINDOW_DESTROY should work or override __del__.
Cody
_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwidgets.org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users
--
orestis@orestis.gr
That worked very well, thanks!
···
--
orestis@orestis.gr
On 11 Dec 2008, at 19:10, Cody Precord wrote:
Hello,
On Thu, Dec 11, 2008 at 12:59 PM, Orestis Markou > <orestis@orestis.gr> wrote:
Hello,
I am making Yet Another Text Editor, using wx.stc. I have a bunch of
editor windows inside an aui.Notebook, and I want to perform cleanup
when a tab is closed. I can detect a closing tab by hooking to
wx.EVT_AUINOTEBOOK_PAGE_CLOSE,
but it seems that there is no equivalent for the stc itself.
I would expect that handling EVT_CLOSE would do it, but it seems that
it's only fired for frames and dialogs.
Because you are not really closing anything, an object is being deleted.
EVT_WINDOW_DESTROY should work or override __del__.
Cody
_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwidgets.org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users