wxPython: "Nesting" wx.NoteBooks?

Piet pit.grinja at gmx.de
Sun Oct 3 18:51:59 CEST 2004


jcarlson at uci.edu (Josiah Carlson) wrote in message news:<88e23673.0410022250.4f8a2933 at posting.google.com>...
> > However, what I get is only the "first level", i.e. a normal NoteBook
> > with three tabs. Is it possible to get the "second level tabs"
> > working?
> 
> Though it is ugly, yes, it can be done.  Nearly anything can be done
> with wxPython, you just need to structure it correctly.
> 
> import wx
> #____________________________
> 
> class MainWindow(wx.Frame):
>     def __init__(self,parent,id,title):
>         self.dirname=''
>         wx.Frame.__init__(self,parent,-4, title,
> style=wx.DEFAULT_FRAME_STYLE)
>         self.Notebook =
> wx.Notebook(self,-1,wx.DefaultPosition,wx.DefaultSize,wx.NB_TOP)
>         self.SubNoteBooks = []
>         
>         for subnotebook in xrange(3):
>             self.SubNoteBooks.append(wx.Notebook(self.Notebook, -1))
>             self.Notebook.AddPage(self.SubNoteBooks[-1],
>                                   'Tab %i'%subnotebook)
>             for i in xrange(3):
>                 self.SubNoteBooks[-1].AddPage(wx.Panel(
>                  self.SubNoteBooks[-1], -1),
>                  'SubTab %i %i'%(subnotebook,i))
> 
> app = wx.PySimpleApp()
> frame = MainWindow(None, -1, "MultiTabControl")
> frame.Show(1)
> app.MainLoop()

Thanks, Josiah. It took me some time to figure out how to put
something on a notebook panel (i.e. in which order the wx.Notebook and
the panel have to be created and which is the child of what), so
leaving out the panel for the "1st level notebooks" would habe
probably the last thing I would have tried.
Piet



More information about the Python-list mailing list