12 #----------------------------------------------------------------------------
14 class TestNB(wx
.Notebook
):
15 def __init__(self
, parent
, id, log
):
16 wx
.Notebook
.__init
__(self
, parent
, id, size
=(21,21), style
=
26 win
= self
.makeColorPanel(wx
.BLUE
)
27 self
.AddPage(win
, "Blue")
28 st
= wx
.StaticText(win
.win
, -1,
29 "You can put nearly any type of window here,\n"
30 "and if the platform supports it then the\n"
31 "tabs can be on any side of the notebook.",
34 st
.SetForegroundColour(wx
.WHITE
)
35 st
.SetBackgroundColour(wx
.BLUE
)
37 # Show how to put an image on one of the notebook tabs,
38 # first make the image list:
39 il
= wx
.ImageList(16, 16)
40 idx1
= il
.Add(images
.getSmilesBitmap())
41 self
.AssignImageList(il
)
43 # now put an image on the first tab we just created:
44 self
.SetPageImage(0, idx1
)
47 win
= self
.makeColorPanel(wx
.RED
)
48 self
.AddPage(win
, "Red")
50 win
= ScrolledWindow
.MyCanvas(self
)
51 self
.AddPage(win
, 'ScrolledWindow')
53 win
= self
.makeColorPanel(wx
.GREEN
)
54 self
.AddPage(win
, "Green")
56 win
= GridSimple
.SimpleGrid(self
, log
)
57 self
.AddPage(win
, "Grid")
59 win
= ListCtrl
.TestListCtrlPanel(self
, log
)
60 self
.AddPage(win
, 'List')
62 win
= self
.makeColorPanel(wx
.CYAN
)
63 self
.AddPage(win
, "Cyan")
65 win
= self
.makeColorPanel(wx
.NamedColour('Midnight Blue'))
66 self
.AddPage(win
, "Midnight Blue")
68 win
= self
.makeColorPanel(wx
.NamedColour('Indian Red'))
69 self
.AddPage(win
, "Indian Red")
71 self
.Bind(wx
.EVT_NOTEBOOK_PAGE_CHANGED
, self
.OnPageChanged
)
72 self
.Bind(wx
.EVT_NOTEBOOK_PAGE_CHANGING
, self
.OnPageChanging
)
75 def makeColorPanel(self
, color
):
76 p
= wx
.Panel(self
, -1)
77 win
= ColorPanel
.ColoredPanel(p
, color
)
79 def OnCPSize(evt
, win
=win
):
80 win
.SetPosition((0,0))
81 win
.SetSize(evt
.GetSize())
82 p
.Bind(wx
.EVT_SIZE
, OnCPSize
)
86 def OnPageChanged(self
, event
):
87 old
= event
.GetOldSelection()
88 new
= event
.GetSelection()
89 sel
= self
.GetSelection()
90 self
.log
.write('OnPageChanged, old:%d, new:%d, sel:%d\n' % (old
, new
, sel
))
93 def OnPageChanging(self
, event
):
94 old
= event
.GetOldSelection()
95 new
= event
.GetSelection()
96 sel
= self
.GetSelection()
97 self
.log
.write('OnPageChanging, old:%d, new:%d, sel:%d\n' % (old
, new
, sel
))
100 #----------------------------------------------------------------------------
102 def runTest(frame
, nb
, log
):
103 testWin
= TestNB(nb
, -1, log
)
106 #----------------------------------------------------------------------------
113 This class represents a notebook control, which manages multiple
114 windows with associated tabs.
116 To use the class, create a wx.Notebook object and call AddPage or
117 InsertPage, passing a window to be used as the page. Do not explicitly
118 delete the window for a page that is currently managed by wx.Notebook.
123 if __name__
== '__main__':
126 run
.main(['', os
.path
.basename(sys
.argv
[0])] + sys
.argv
[1:])