12 #----------------------------------------------------------------------------
14 class TestNB(wx
.Notebook
):
15 def __init__(self
, parent
, id, log
):
16 wx
.Notebook
.__init
__(self
, parent
, id, size
=(21,21),
18 #wx.NB_TOP # | wx.NB_MULTILINE
25 win
= self
.makeColorPanel(wx
.BLUE
)
26 self
.AddPage(win
, "Blue")
27 st
= wx
.StaticText(win
.win
, -1,
28 "You can put nearly any type of window here,\n"
29 "and if the platform supports it then the\n"
30 "tabs can be on any side of the notebook.",
33 st
.SetForegroundColour(wx
.WHITE
)
34 st
.SetBackgroundColour(wx
.BLUE
)
36 # Show how to put an image on one of the notebook tabs,
37 # first make the image list:
38 il
= wx
.ImageList(16, 16)
39 idx1
= il
.Add(images
.getSmilesBitmap())
40 self
.AssignImageList(il
)
42 # now put an image on the first tab we just created:
43 self
.SetPageImage(0, idx1
)
46 win
= self
.makeColorPanel(wx
.RED
)
47 self
.AddPage(win
, "Red")
49 win
= ScrolledWindow
.MyCanvas(self
)
50 self
.AddPage(win
, 'ScrolledWindow')
52 win
= self
.makeColorPanel(wx
.GREEN
)
53 self
.AddPage(win
, "Green")
55 win
= GridSimple
.SimpleGrid(self
, log
)
56 self
.AddPage(win
, "Grid")
58 win
= ListCtrl
.TestListCtrlPanel(self
, log
)
59 self
.AddPage(win
, 'List')
61 win
= self
.makeColorPanel(wx
.CYAN
)
62 self
.AddPage(win
, "Cyan")
64 # win = self.makeColorPanel(wxWHITE)
65 # self.AddPage(win, "White")
67 # win = self.makeColorPanel(wxBLACK)
68 # self.AddPage(win, "Black")
70 win
= self
.makeColorPanel(wx
.NamedColour('MIDNIGHT BLUE'))
71 self
.AddPage(win
, "MIDNIGHT BLUE")
73 win
= self
.makeColorPanel(wx
.NamedColour('INDIAN RED'))
74 self
.AddPage(win
, "INDIAN RED")
76 self
.Bind(wx
.EVT_NOTEBOOK_PAGE_CHANGED
, self
.OnPageChanged
)
77 self
.Bind(wx
.EVT_NOTEBOOK_PAGE_CHANGING
, self
.OnPageChanging
)
80 def makeColorPanel(self
, color
):
81 p
= wx
.Panel(self
, -1)
82 win
= ColorPanel
.ColoredPanel(p
, color
)
85 def OnCPSize(evt
, win
=win
):
86 win
.SetSize(evt
.GetSize())
88 p
.Bind(wx
.EVT_SIZE
, OnCPSize
)
91 def OnPageChanged(self
, event
):
92 old
= event
.GetOldSelection()
93 new
= event
.GetSelection()
94 sel
= self
.GetSelection()
95 self
.log
.write('OnPageChanged, old:%d, new:%d, sel:%d\n' % (old
, new
, sel
))
98 def OnPageChanging(self
, event
):
99 old
= event
.GetOldSelection()
100 new
= event
.GetSelection()
101 sel
= self
.GetSelection()
102 self
.log
.write('OnPageChanging, old:%d, new:%d, sel:%d\n' % (old
, new
, sel
))
105 #----------------------------------------------------------------------------
107 def runTest(frame
, nb
, log
):
108 testWin
= TestNB(nb
, -1, log
)
111 #----------------------------------------------------------------------------
118 This class represents a notebook control, which manages multiple
119 windows with associated tabs.
121 To use the class, create a wx.Notebook object and call AddPage or
122 InsertPage, passing a window to be used as the page. Do not explicitly
123 delete the window for a page that is currently managed by wx.Notebook.
128 if __name__
== '__main__':
131 run
.main(['', os
.path
.basename(sys
.argv
[0])] + sys
.argv
[1:])