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(wxWHITE)
66 # self.AddPage(win, "White")
68 # win = self.makeColorPanel(wxBLACK)
69 # self.AddPage(win, "Black")
71 win
= self
.makeColorPanel(wx
.NamedColour('MIDNIGHT BLUE'))
72 self
.AddPage(win
, "MIDNIGHT BLUE")
74 win
= self
.makeColorPanel(wx
.NamedColour('INDIAN RED'))
75 self
.AddPage(win
, "INDIAN RED")
77 self
.Bind(wx
.EVT_NOTEBOOK_PAGE_CHANGED
, self
.OnPageChanged
)
78 self
.Bind(wx
.EVT_NOTEBOOK_PAGE_CHANGING
, self
.OnPageChanging
)
81 def makeColorPanel(self
, color
):
82 p
= wx
.Panel(self
, -1)
83 win
= ColorPanel
.ColoredPanel(p
, color
)
86 def OnCPSize(evt
, win
=win
):
87 win
.SetSize(evt
.GetSize())
89 p
.Bind(wx
.EVT_SIZE
, OnCPSize
)
92 def OnPageChanged(self
, event
):
93 old
= event
.GetOldSelection()
94 new
= event
.GetSelection()
95 sel
= self
.GetSelection()
96 self
.log
.write('OnPageChanged, old:%d, new:%d, sel:%d\n' % (old
, new
, sel
))
99 def OnPageChanging(self
, event
):
100 old
= event
.GetOldSelection()
101 new
= event
.GetSelection()
102 sel
= self
.GetSelection()
103 self
.log
.write('OnPageChanging, old:%d, new:%d, sel:%d\n' % (old
, new
, sel
))
106 #----------------------------------------------------------------------------
108 def runTest(frame
, nb
, log
):
109 testWin
= TestNB(nb
, -1, log
)
112 #----------------------------------------------------------------------------
119 This class represents a notebook control, which manages multiple
120 windows with associated tabs.
122 To use the class, create a wx.Notebook object and call AddPage or
123 InsertPage, passing a window to be used as the page. Do not explicitly
124 delete the window for a page that is currently managed by wx.Notebook.
129 if __name__
== '__main__':
132 run
.main(['', os
.path
.basename(sys
.argv
[0])] + sys
.argv
[1:])