]> git.saurik.com Git - wxWidgets.git/blame - wxPython/demo/Toolbook.py
Use the static method instead of the global alias
[wxWidgets.git] / wxPython / demo / Toolbook.py
CommitLineData
6aabc8da
RD
1
2import wx
3
4import ColorPanel
5import images
6
7colourList = [ "Aquamarine", "Grey", "Blue", "Blue Violet", "Brown", "Cadet Blue",
8 "Coral", "Wheat", #"Cyan", "Dark Grey", "Dark Green",
9 #"Steel Blue",
10 ]
11
12#----------------------------------------------------------------------------
13
14def getNextImageID(count):
15 imID = 0
16 while True:
17 yield imID
18 imID += 1
19 if imID == count:
20 imID = 0
21
22
23class TestTB(wx.Toolbook):
24 def __init__(self, parent, id, log):
25 wx.Toolbook.__init__(self, parent, id, style=
26 wx.BK_DEFAULT
27 #wx.BK_TOP
28 #wx.BK_BOTTOM
29 #wx.BK_LEFT
30 #wx.BK_RIGHT
31 )
32 self.log = log
33
34 # make an image list using the LBXX images
35 il = wx.ImageList(32, 32)
36 for x in range(12):
37 f = getattr(images, 'getLB%02dBitmap' % (x+1))
38 bmp = f()
39 il.Add(bmp)
40 self.AssignImageList(il)
41 imageIdGenerator = getNextImageID(il.GetImageCount())
42
43 # Now make a bunch of panels for the list book
44 first = True
45 for colour in colourList:
46 win = self.makeColorPanel(colour)
47 self.AddPage(win, colour, imageId=imageIdGenerator.next())
48 if first:
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",
52 wx.Point(10, 10))
53 first = False
54
55 self.Bind(wx.EVT_TOOLBOOK_PAGE_CHANGED, self.OnPageChanged)
56 self.Bind(wx.EVT_TOOLBOOK_PAGE_CHANGING, self.OnPageChanging)
57
58
59 def makeColorPanel(self, color):
60 p = wx.Panel(self, -1)
61 win = ColorPanel.ColoredPanel(p, color)
62 p.win = win
63 def OnCPSize(evt, win=win):
e79c4165 64 win.SetPosition((0,0))
6aabc8da
RD
65 win.SetSize(evt.GetSize())
66 p.Bind(wx.EVT_SIZE, OnCPSize)
67 return p
68
69
70 def OnPageChanged(self, event):
71 old = event.GetOldSelection()
72 new = event.GetSelection()
73 sel = self.GetSelection()
74 self.log.write('OnPageChanged, old:%d, new:%d, sel:%d\n' % (old, new, sel))
75 event.Skip()
76
77 def OnPageChanging(self, event):
78 old = event.GetOldSelection()
79 new = event.GetSelection()
80 sel = self.GetSelection()
81 self.log.write('OnPageChanging, old:%d, new:%d, sel:%d\n' % (old, new, sel))
82 event.Skip()
83
84#----------------------------------------------------------------------------
85
86def runTest(frame, nb, log):
87 testWin = TestTB(nb, -1, log)
88 return testWin
89
90#----------------------------------------------------------------------------
91
92
93overview = """\
94<html><body>
95<h2>wx.Toolbook</h2>
96<p>
97This class is a control similar to a notebook control, but with a
98wx.Toolbar instead of a set of tabs.
99
100"""
101
102
103
104if __name__ == '__main__':
105 import sys,os
106 import run
107 run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])
108
109
110