[wxPython] wxNotebook GetPage() should return obj that was AddPage'd, no?

Robin Dunn said:

All wxNotebook knows about are the C++ objects you give it. The
next phase of the OOR will add the knowledge of which original
python objects are wrapping the C++ objects.

spent about 20 msec with wxwindows2.cpp and decided it'd be quicker
for now just to write a wrapper class for wxNotebook.
sounds like OOR is goin in the right direction.

les schaffer

with due apologies for the name:

···

--------------------------------

class SaneNotebook(wxNotebook):

    """Make wxNotebook more list-like by keeping a list of references
    to pages as they are added. This way GetPage() returns the object
    we AddPage'd/InsertPage'd. """

    def __init__(self, *args):
        apply(wxNotebook.__init__, (self,)+args)
        self._PageList =
    
    def AddPage(self, page, *args ):
        apply(wxNotebook.AddPage, (self, page,)+args)
        self._PageList.append(page)

    def InsertPage(self, index, page, *args):
        apply(wxNotebook.InsertPage, (self, index, page,)+args)
        self._PageList.insert(page, index)

    def GetPage(self, npage):
        """The reason for this class' existence."""
        return self._PageList[npage]

    def GetPageWindow(self, npage):
        return wxNotebook.GetPage(self, npage)

    def DeleteAllPages(self):
        self._PageList =
        wxNotebook.DeleteAllPages(self)

    def DeletePage(self, npage):
        del self._PageList[npage]
        wxNotebook.DeletePage(self, npage)