Notebook in a Notebook

Hello all,

I have a simple example i am working on, adding more complexity to it, so i can be sure of what is the problem (advice taken from this list!)
I encounter a problem when trying to add a Notebook as a panel, in an bigger notebook’s tab.

My example works IF you comment out the piece of code between the ‘#’ lines, and uncomment the two lines above that (the yellow panel).
So when i try to add the new notebook it crashes, i’d like to know what i am doing wrong.

Am i doing the right thing when creating the new notebook in its own panel, and adding that panel to the big notebook’s tab/panel ?

Anyway, here is the code, any help would be appreciated !

Cheers,

Thomas.

···

#CODE:

import wx

class myPanel(wx.Panel):
def init(self, parent):
wx.Panel.init(self, parent)

    ###
    ### 1st panel

    ###
   
    self.panel1=wx.Panel(self, wx.ID_ANY)
   
    up=wx.Panel(self.panel1, wx.ID_ANY)
    up.SetBackgroundColour("Red")
    down=wx.Panel(self.panel1, wx.ID_ANY)

    down.SetBackgroundColour("Blue")
   
    sizer1=wx.StaticBoxSizer(wx.StaticBox(self.panel1, wx.ID_ANY, 'Test'), orient=wx.VERTICAL)
    self.panel1.SetSizer(sizer1)
    sizer1.Add(up, 1, wx.EXPAND)

    sizer1.Add(down, 1, wx.EXPAND)
   
    ###
    ### 2nd panel
    ###
   
    self.panel2=wx.Panel(self, wx.ID_ANY)
    sizer2=wx.StaticBoxSizer(wx.StaticBox(self.panel2, wx.ID_ANY, 'List'), orient=wx.VERTICAL)

   
    self.listCtrl=wx.ListCtrl(self.panel2, wx.ID_ANY, style=wx.LC_REPORT | wx.SUNKEN_BORDER)
    self.listCtrl.InsertColumn(0, "Name")
    self.listCtrl.InsertColumn(1, "Rank")

   
    self.panel2.SetSizer(sizer2)
    sizer2.Add(self.listCtrl, 1, wx.EXPAND)
   
    ###
    ### 3rd panel
    ###
   
    self.panel3=wx.Panel(self, wx.ID_ANY)

    sizer3=wx.StaticBoxSizer(wx.StaticBox(self.panel3, wx.ID_ANY, 'Tabs'), orient=wx.VERTICAL)
   
    #notePanel=wx.Panel(self.panel3, wx.ID_ANY)
    #notePanel.SetBackgroundColour("Yellow")

#########################

    notePanel=wx.Panel(self.panel3, wx.ID_ANY)       
    note=wx.Notebook(notePanel, wx.ID_ANY)
   
    tab1=wx.Panel(note, wx.ID_ANY)
    tab1.SetBackgroundColour("Yellow")

    tab2=wx.Panel(note, wx.ID_ANY)
    tab2.SetBackgroundColour("Green")
    tab3=wx.Panel(note, wx.ID_ANY)
    tab3.SetBackgroundColour("Blue")
   
    note.Add(tab1, "tab1")

    note.Add(tab2, "tab2")
    note.Add(tab3, "tab3")
   
    noteSizer=wx.BoxSizer()
    noteSizer.Add(note, 1, wx.EXPAND)       
    notePanel.SetSizer(noteSizer)

#########################

    self.panel3.SetSizer(sizer3)
    sizer3.Add(notePanel, 1, wx.EXPAND)
   
    ###
    ### add the panels
    ###
   
    self.mainSizer=wx.BoxSizer(wx.HORIZONTAL)

   
    self.SetSizer(self.mainSizer)
   
    self.mainSizer.Add(self.panel1, 1, wx.EXPAND)
    self.mainSizer.Add(self.panel2, 1, wx.EXPAND)  
    self.mainSizer.Add(self.panel3, 1, wx.EXPAND)

class MainFrame(wx.Frame):
def init(self):
wx.Frame.init(self, None, title=“Layout Example”)

    panel=wx.Panel(self, wx.ID_ANY)
    notebook=wx.Notebook(panel, wx.ID_ANY)

   
    #calling the classes defined here, to create the pages
    self.myTab=myPanel(notebook)

    #adding them to the notebook
    notebook.AddPage(self.myTab, "TAB")

   
    sizer=wx.BoxSizer()
   
    panel.SetSizer(sizer)
    sizer.Add(notebook, 1, wx.EXPAND)

if name == “main”:
app = wx.App()
MainFrame().Show()

app.MainLoop()