]>
Commit | Line | Data |
---|---|---|
2f0f3b0f | 1 | |
8fa876ca | 2 | import wx |
2f0f3b0f | 3 | |
372bde9b | 4 | import ColorPanel |
95bfd958 | 5 | import images |
372bde9b | 6 | |
fbd5dd1d RD |
7 | colourList = [ "Aquamarine", "Black", "Blue", "Blue Violet", "Brown", "Cadet Blue", |
8 | "Coral", "Cornflower Blue", "Cyan", "Dark Grey", "Dark Green", | |
6c75a4cf | 9 | "Dark Olive Green", |
fbd5dd1d | 10 | ] |
2f0f3b0f RD |
11 | |
12 | #---------------------------------------------------------------------------- | |
13 | ||
8fa876ca | 14 | class TestLB(wx.Listbook): |
2f0f3b0f | 15 | def __init__(self, parent, id, log): |
8fa876ca RD |
16 | wx.Listbook.__init__(self, parent, id, style= |
17 | wx.LB_DEFAULT | |
2f0f3b0f RD |
18 | #wxLB_TOP |
19 | #wxLB_BOTTOM | |
20 | #wxLB_LEFT | |
21 | #wxLB_RIGHT | |
22 | ) | |
23 | self.log = log | |
24 | ||
6c75a4cf | 25 | # make an image list using the LBXX images |
372bde9b | 26 | il = wx.ImageList(32, 32) |
6c75a4cf RD |
27 | for x in range(12): |
28 | f = getattr(images, 'getLB%02dBitmap' % (x+1)) | |
fbd5dd1d RD |
29 | bmp = f() |
30 | il.Add(bmp) | |
2f0f3b0f | 31 | self.AssignImageList(il) |
fbd5dd1d RD |
32 | |
33 | # Now make a bunch of panels for the list book | |
34 | first = True | |
35 | imID = 0 | |
36 | for colour in colourList: | |
37 | win = self.makeColorPanel(colour) | |
38 | self.AddPage(win, colour, imageId=imID) | |
39 | imID += 1 | |
40 | if imID == il.GetImageCount(): imID = 0 | |
41 | if first: | |
372bde9b | 42 | st = wx.StaticText(win.win, -1, |
fbd5dd1d RD |
43 | "You can put nearly any type of window here,\n" |
44 | "and the list can be on any side of the Listbook", | |
372bde9b | 45 | wx.Point(10, 10)) |
fbd5dd1d | 46 | first = False |
2f0f3b0f | 47 | |
f12166fc RD |
48 | self.Bind(wx.EVT_LISTBOOK_PAGE_CHANGED, self.OnPageChanged) |
49 | self.Bind(wx.EVT_LISTBOOK_PAGE_CHANGING, self.OnPageChanging) | |
2f0f3b0f RD |
50 | |
51 | ||
52 | def makeColorPanel(self, color): | |
8fa876ca | 53 | p = wx.Panel(self, -1) |
2f0f3b0f RD |
54 | win = ColorPanel.ColoredPanel(p, color) |
55 | p.win = win | |
56 | def OnCPSize(evt, win=win): | |
57 | win.SetSize(evt.GetSize()) | |
8fa876ca | 58 | p.Bind(wx.EVT_SIZE, OnCPSize) |
2f0f3b0f RD |
59 | return p |
60 | ||
61 | ||
62 | def OnPageChanged(self, event): | |
63 | old = event.GetOldSelection() | |
64 | new = event.GetSelection() | |
65 | sel = self.GetSelection() | |
66 | self.log.write('OnPageChanged, old:%d, new:%d, sel:%d\n' % (old, new, sel)) | |
67 | event.Skip() | |
68 | ||
69 | def OnPageChanging(self, event): | |
70 | old = event.GetOldSelection() | |
71 | new = event.GetSelection() | |
72 | sel = self.GetSelection() | |
73 | self.log.write('OnPageChanging, old:%d, new:%d, sel:%d\n' % (old, new, sel)) | |
74 | event.Skip() | |
75 | ||
76 | #---------------------------------------------------------------------------- | |
77 | ||
78 | def runTest(frame, nb, log): | |
79 | testWin = TestLB(nb, -1, log) | |
80 | return testWin | |
81 | ||
82 | #---------------------------------------------------------------------------- | |
83 | ||
84 | ||
2f0f3b0f RD |
85 | overview = """\ |
86 | <html><body> | |
95bfd958 | 87 | <h2>wx.Listbook</h2> |
2f0f3b0f RD |
88 | <p> |
89 | This class is a control similar to a notebook control, but with a | |
95bfd958 | 90 | wx.ListCtrl instead of a set of tabs. |
2f0f3b0f RD |
91 | |
92 | """ | |
93 | ||
94 | ||
95 | ||
96 | if __name__ == '__main__': | |
97 | import sys,os | |
98 | import run | |
8eca4fef | 99 | run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:]) |
2f0f3b0f RD |
100 | |
101 | ||
f12166fc | 102 |