wxPython: "Nesting" wx.NoteBooks?

P

Piet

Hi,
I am trying to generate an "hierarchical" layout based on
wx.NoteBooks. That means, every page of a Notebook should be a
NoteBookon its own. Here is a (short but complicated) piece of code
that I put together to see whether it works:

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.panels = []
self.SubNoteBooks = []

for panelNumber in range(3):
self.panels.append(wx.Panel(self.Notebook,-1))
self.Notebook.AddPage(self.panels[panelNumber],"Tab"+str(panelNumber))#
self.SubNoteBooks.append(wx.Notebook(self.panels[panelNumber],-1,wx.DefaultPosition,wx.DefaultSize,wx.NB_TOP))
self.SubNoteBooks[panelNumber].subPanels = []
for subPanelNumber in range(3):
self.SubNoteBooks[panelNumber].subPanels.append(wx.Panel(self.SubNoteBooks[panelNumber],-1))
self.SubNoteBooks[panelNumber].AddPage(self.SubNoteBooks[panelNumber].subPanels[subPanelNumber],"Subtab"+str(panelNumber)+str(subPanelNumber))

app = wx.PySimpleApp()
frame = MainWindow(None, -1, "MultiTabControl")
frame.Show(1)
app.MainLoop()

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?
Many thanks in advance
Piet
 
J

Jeff Epler

If you can find a serious User Interface Guide that recommends nesting
Notebook-type widgets, I'll try to help you answer this question.

It's nice that what you're asking for is apparently hard to provide,
because users will hate it, or else fail entirely to grasp what is going
on.

Jeff

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQFBXbs6Jd01MZaTXX0RAganAJ4oPbDuEQUv6W9ZnYuLyDZYu2Qw6gCfcmtZ
utpzKknryY3bFUQItns1/kQ=
=Yi+J
-----END PGP SIGNATURE-----
 
J

Josiah Carlson

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()
 
P

Piet

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,731
Messages
2,569,432
Members
44,835
Latest member
KetoRushACVBuy

Latest Threads

Top