New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DeletePage of wx.aui.AuiNotebook not working #888

Closed
jensgoe opened this Issue Jun 18, 2018 · 4 comments

Comments

Projects
None yet
5 participants
@jensgoe
Copy link
Contributor

jensgoe commented Jun 18, 2018

Operating system: win7
wxPython version: 4.0.2
Stock or custom build: stock
Python version: 2.7.15
Stock or custom build: stock

Description of the problem:

Pages of an AuiNotebook (wx.aui) cannote be removed anymore.

  1. Run the wxPython Demo
  2. Select AUI_Notebook
  3. Click the "X" button on the page to close it
  4. nothing happens

This relates to #820 (#832).

Removing the following lines of code in core.py fixed this for me.

BookCtrlBase.RemovePage = _checkBookPageCount(BookCtrlBase.RemovePage)
BookCtrlBase.GetPage = _checkBookPageCount(BookCtrlBase.GetPage)

It seems the RemovePage method of the base class (BookCtrlBase) is called instead of wxAuiNotebook::RemovePage?

@PonyPC

This comment has been minimized.

Copy link

PonyPC commented Jun 30, 2018

ME TOO!!!

@imKLM

This comment has been minimized.

Copy link

imKLM commented Jul 9, 2018

Same here, currently have a class inheriting from wx.aui.AuiNotebook which adds specific functionality i need.
Within my override for DeletePage i make a call to:
if super(MyNotebook, self).DeletePage(page_index):
which always seems to return False,
wxPython Version: 4.0.3
Python version: 3.6

@RobinD42

This comment has been minimized.

Copy link
Member

RobinD42 commented Jul 21, 2018

Fixed by #939

@RobinD42 RobinD42 closed this Jul 21, 2018

@struts2spring

This comment has been minimized.

Copy link

struts2spring commented Oct 16, 2018

Try

#!/usr/bin/env python

import wx
import wx.lib.agw.aui.auibook as aui

text = """\
Hello!
Welcome to this little demo of draggable tabs using the aui module.
To try it out, drag a tab from the top of the window all the way to the bottom.  After releasing the mouse, the tab will dock at the hinted position.  Then try it again with the remaining tabs in various other positions.  Finally, try dragging a tab to an existing tab ctrl.  You'll soon see that very complex tab layouts may be achieved.
"""

#----------------------------------------------------------------------


class TestPanel(wx.Panel):

    def __init__(self, parent):
        wx.Panel.__init__(self, parent, -1)

        self.nb = aui.AuiNotebook(self)
        page = wx.TextCtrl(self.nb, -1, text, style=wx.TE_MULTILINE)
        self.nb.AddPage(page, "Welcome")

        for num in range(1, 5):
            page = wx.TextCtrl(self.nb, -1, "This is page %d" % num ,
                               style=wx.TE_MULTILINE)
            self.nb.AddPage(page, "Tab Number %d" % num)

        sizer = wx.BoxSizer()
        sizer.Add(self.nb, 1, wx.EXPAND)
        self.SetSizer(sizer)
        wx.CallAfter(self.nb.SendSizeEvent)
        self.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED, self.OnPageChanged)
        self.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGING, self.OnPageChanging)
        self.Bind(aui.EVT_AUINOTEBOOK_PAGE_CLOSED, self.OnPageClose)

    def OnPageClose(self, event):
        print('OnPageClose')
        self.nb.DeletePage(0)
    def OnPageChanged(self, event):
        if self:
            old = event.GetOldSelection()
            new = event.GetSelection()
            sel = self.GetSelection()
            print('OnPageChanged,  old:%d, new:%d, sel:%d\n' % (old, new, sel))
        event.Skip()

    def OnPageChanging(self, event):
        if self:
            old = event.GetOldSelection()
            new = event.GetSelection()
            sel = self.GetSelection()
            print('OnPageChanging, old:%d, new:%d, sel:%d\n' % (old, new, sel))
        event.Skip()
########################################################################
class DemoFrame(wx.Frame):
    """
    wx.Frame class
    """

    #----------------------------------------------------------------------
    def __init__(self):
        wx.Frame.__init__(self, None, wx.ID_ANY,
                          "AGW AUI Notebook Tutorial",
                          size=(600, 400))
        self.testPanel = TestPanel(self)

        
#----------------------------------------------------------------------
# Run the program
if __name__ == "__main__":
    app = wx.App()
    frame = DemoFrame()
    frame.Show()
    app.MainLoop()        
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment