7 colourList
= [ "Aquamarine", "Grey", "Blue", "Blue Violet", "Brown", "Cadet Blue",
8 "Coral", "Wheat", #"Cyan", "Dark Grey", "Dark Green",
12 #----------------------------------------------------------------------------
14 def getNextImageID(count
):
23 class TestTB(wx
.Toolbook
):
24 def __init__(self
, parent
, id, log
):
25 wx
.Toolbook
.__init
__(self
, parent
, id, style
=
34 # make an image list using the LBXX images
35 il
= wx
.ImageList(32, 32)
37 f
= getattr(images
, 'getLB%02dBitmap' % (x
+1))
40 self
.AssignImageList(il
)
41 imageIdGenerator
= getNextImageID(il
.GetImageCount())
43 # Now make a bunch of panels for the list book
45 for colour
in colourList
:
46 win
= self
.makeColorPanel(colour
)
47 self
.AddPage(win
, colour
, imageId
=imageIdGenerator
.next())
49 st
= wx
.StaticText(win
.win
, -1,
50 "You can put nearly any type of window here,\n"
51 "and the toolbar can be on either side of the Toolbook",
55 self
.Bind(wx
.EVT_TOOLBOOK_PAGE_CHANGED
, self
.OnPageChanged
)
56 self
.Bind(wx
.EVT_TOOLBOOK_PAGE_CHANGING
, self
.OnPageChanging
)
59 def makeColorPanel(self
, color
):
60 p
= wx
.Panel(self
, -1)
61 win
= ColorPanel
.ColoredPanel(p
, color
)
63 def OnCPSize(evt
, win
=win
):
64 win
.SetSize(evt
.GetSize())
65 p
.Bind(wx
.EVT_SIZE
, OnCPSize
)
69 def OnPageChanged(self
, event
):
70 old
= event
.GetOldSelection()
71 new
= event
.GetSelection()
72 sel
= self
.GetSelection()
73 self
.log
.write('OnPageChanged, old:%d, new:%d, sel:%d\n' % (old
, new
, sel
))
76 def OnPageChanging(self
, event
):
77 old
= event
.GetOldSelection()
78 new
= event
.GetSelection()
79 sel
= self
.GetSelection()
80 self
.log
.write('OnPageChanging, old:%d, new:%d, sel:%d\n' % (old
, new
, sel
))
83 #----------------------------------------------------------------------------
85 def runTest(frame
, nb
, log
):
86 testWin
= TestTB(nb
, -1, log
)
89 #----------------------------------------------------------------------------
96 This class is a control similar to a notebook control, but with a
97 wx.Toolbar instead of a set of tabs.
103 if __name__
== '__main__':
106 run
.main(['', os
.path
.basename(sys
.argv
[0])] + sys
.argv
[1:])