12 #----------------------------------------------------------------------------
14 class TestNB(wx
.Notebook
):
15 def __init__(self
, parent
, id, log
):
16 wx
.Notebook
.__init
__(self
, parent
, id, style
=
24 win
= self
.makeColorPanel(wx
.BLUE
)
25 self
.AddPage(win
, "Blue")
26 st
= wx
.StaticText(win
.win
, -1,
27 "You can put nearly any type of window here,\n"
28 "and if the platform supports it then the\n"
29 "tabs can be on any side of the notebook.",
32 st
.SetForegroundColour(wx
.WHITE
)
33 st
.SetBackgroundColour(wx
.BLUE
)
35 # Show how to put an image on one of the notebook tabs,
36 # first make the image list:
37 il
= wx
.ImageList(16, 16)
38 idx1
= il
.Add(images
.getSmilesBitmap())
39 self
.AssignImageList(il
)
41 # now put an image on the first tab we just created:
42 self
.SetPageImage(0, idx1
)
45 win
= self
.makeColorPanel(wx
.RED
)
46 self
.AddPage(win
, "Red")
48 win
= ScrolledWindow
.MyCanvas(self
)
49 self
.AddPage(win
, 'ScrolledWindow')
51 win
= self
.makeColorPanel(wx
.GREEN
)
52 self
.AddPage(win
, "Green")
54 win
= GridSimple
.SimpleGrid(self
, log
)
55 self
.AddPage(win
, "Grid")
57 win
= ListCtrl
.TestListCtrlPanel(self
, log
)
58 self
.AddPage(win
, 'List')
60 win
= self
.makeColorPanel(wx
.CYAN
)
61 self
.AddPage(win
, "Cyan")
63 # win = self.makeColorPanel(wxWHITE)
64 # self.AddPage(win, "White")
66 # win = self.makeColorPanel(wxBLACK)
67 # self.AddPage(win, "Black")
69 win
= self
.makeColorPanel(wx
.NamedColour('MIDNIGHT BLUE'))
70 self
.AddPage(win
, "MIDNIGHT BLUE")
72 win
= self
.makeColorPanel(wx
.NamedColour('INDIAN RED'))
73 self
.AddPage(win
, "INDIAN RED")
75 self
.Bind(wx
.EVT_NOTEBOOK_PAGE_CHANGED
, self
.OnPageChanged
)
76 self
.Bind(wx
.EVT_NOTEBOOK_PAGE_CHANGING
, self
.OnPageChanging
)
79 def makeColorPanel(self
, color
):
80 p
= wx
.Panel(self
, -1)
81 win
= ColorPanel
.ColoredPanel(p
, color
)
84 def OnCPSize(evt
, win
=win
):
85 win
.SetSize(evt
.GetSize())
87 p
.Bind(wx
.EVT_SIZE
, OnCPSize
)
90 def OnPageChanged(self
, event
):
91 old
= event
.GetOldSelection()
92 new
= event
.GetSelection()
93 sel
= self
.GetSelection()
94 self
.log
.write('OnPageChanged, old:%d, new:%d, sel:%d\n' % (old
, new
, sel
))
97 def OnPageChanging(self
, event
):
98 old
= event
.GetOldSelection()
99 new
= event
.GetSelection()
100 sel
= self
.GetSelection()
101 self
.log
.write('OnPageChanging, old:%d, new:%d, sel:%d\n' % (old
, new
, sel
))
104 #----------------------------------------------------------------------------
106 def runTest(frame
, nb
, log
):
107 testWin
= TestNB(nb
, -1, log
)
110 #----------------------------------------------------------------------------
117 This class represents a notebook control, which manages multiple
118 windows with associated tabs.
120 To use the class, create a wx.Notebook object and call AddPage or
121 InsertPage, passing a window to be used as the page. Do not explicitly
122 delete the window for a page that is currently managed by wx.Notebook.
127 if __name__
== '__main__':
130 run
.main(['', os
.path
.basename(sys
.argv
[0])] + sys
.argv
[1:])