Search code examples
pythonwxpythonwxwidgets

Put an AuiManager inside a AuiNotebook page


Is it possible ho put an AuiManager inside an AuiNotebook page?

Have tested with a small sample code, but I only get a 'Segmentation fault'.

Is this possible to begin with? The reason why I want this is to split a notebook page in two parts and get the caption field and the maximize field in the top of each part of the two parts. A simple splitterwindow would work but does not look as good and cannot be maximized as easily. And nor does it have the caption field.

Sample code below.

import wx
import wx.aui

import wx.lib.inspection

class MyFrame(wx.Frame):
    def __init__(self, *args, **kwargs):
        wx.Frame.__init__(self, *args, **kwargs)

        self.mgr = wx.aui.AuiManager(self)

        self.left = wx.Panel(self, -1, size = (200, 150))
        self.right = wx.aui.AuiNotebook(self, -1, size = (200, 150))
        self.bottom = wx.Panel(self, -1, size = (200, 150))

        self.mgr.AddPane(self.bottom, wx.aui.AuiPaneInfo().Bottom())
        self.mgr.AddPane(self.left, wx.aui.AuiPaneInfo().Left().Layer(1))
        self.mgr.AddPane(self.right, wx.aui.AuiPaneInfo().CenterPane())

        self.new_panel('Panel 1')

        self.mgr.Update()
        self.Update()

    def new_panel(self, nm):
        pnl = wx.Window(self)
        pnl.identifierTag = nm
        self.right.AddPage(pnl, nm, select = True)
        self.sizer = wx.BoxSizer()
        self.sizer.Add(self.right, 1, wx.EXPAND)
        self.SetSizer(self.sizer)
        pnl.SetFocus()

        mgr = wx.aui.AuiManager(pnl)

        left = wx.Panel(self)
        right = wx.Panel(self)

        mgr.AddPane(left, wx.aui.AuiPaneInfo().Left())
        mgr.AddPane(right, wx.aui.AuiPaneInfo().Right())

        mgr.Update()

class MyApp(wx.App):
    def OnInit(self):
        frame = MyFrame(None, -1, '07_wxaui.py')
        frame.Show()
        self.SetTopWindow(frame)
        return 1

if __name__ == "__main__":
    app = MyApp(0)
    wx.lib.inspection.InspectionTool().Show()

    app.MainLoop()

Solution

  • wxAUIManager only works as a child of a wxFrame.

    http://docs.wxwidgets.org/trunk/classwx_aui_manager.html