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