]>
Commit | Line | Data |
---|---|---|
1 | ||
2 | import sys | |
3 | ||
4 | import wx | |
5 | ||
6 | import ColorPanel | |
7 | import images | |
8 | ||
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 | ] | |
25 | ||
26 | #---------------------------------------------------------------------------- | |
27 | ||
28 | class TestLB(wx.Listbook): | |
29 | def __init__(self, parent, id, log): | |
30 | wx.Listbook.__init__(self, parent, id, style= | |
31 | wx.LB_DEFAULT | |
32 | #wxLB_TOP | |
33 | #wxLB_BOTTOM | |
34 | #wxLB_LEFT | |
35 | #wxLB_RIGHT | |
36 | ) | |
37 | self.log = log | |
38 | ||
39 | # make an image list using the BlomXX images | |
40 | il = wx.ImageList(32, 32) | |
41 | for x in range(1, 15): | |
42 | f = getattr(images, 'getBlom%02dBitmap' % x) | |
43 | bmp = f() | |
44 | il.Add(bmp) | |
45 | self.AssignImageList(il) | |
46 | ||
47 | # Now make a bunch of panels for the list book | |
48 | first = True | |
49 | imID = 0 | |
50 | for colour in colourList: | |
51 | win = self.makeColorPanel(colour) | |
52 | self.AddPage(win, colour, imageId=imID) | |
53 | imID += 1 | |
54 | if imID == il.GetImageCount(): imID = 0 | |
55 | if first: | |
56 | st = wx.StaticText(win.win, -1, | |
57 | "You can put nearly any type of window here,\n" | |
58 | "and the list can be on any side of the Listbook", | |
59 | wx.Point(10, 10)) | |
60 | #st.SetForegroundColour(wxWHITE) | |
61 | #st.SetBackgroundColour(wxBLUE) | |
62 | first = False | |
63 | ||
64 | self.Bind(wx.EVT_LISTBOOK_PAGE_CHANGED, self.OnPageChanged) | |
65 | self.Bind(wx.EVT_LISTBOOK_PAGE_CHANGING, self.OnPageChanging) | |
66 | ||
67 | ||
68 | def makeColorPanel(self, color): | |
69 | p = wx.Panel(self, -1) | |
70 | win = ColorPanel.ColoredPanel(p, color) | |
71 | p.win = win | |
72 | def OnCPSize(evt, win=win): | |
73 | win.SetSize(evt.GetSize()) | |
74 | p.Bind(wx.EVT_SIZE, OnCPSize) | |
75 | return p | |
76 | ||
77 | ||
78 | def OnPageChanged(self, event): | |
79 | old = event.GetOldSelection() | |
80 | new = event.GetSelection() | |
81 | sel = self.GetSelection() | |
82 | self.log.write('OnPageChanged, old:%d, new:%d, sel:%d\n' % (old, new, sel)) | |
83 | event.Skip() | |
84 | ||
85 | def OnPageChanging(self, event): | |
86 | old = event.GetOldSelection() | |
87 | new = event.GetSelection() | |
88 | sel = self.GetSelection() | |
89 | self.log.write('OnPageChanging, old:%d, new:%d, sel:%d\n' % (old, new, sel)) | |
90 | event.Skip() | |
91 | ||
92 | #---------------------------------------------------------------------------- | |
93 | ||
94 | def runTest(frame, nb, log): | |
95 | testWin = TestLB(nb, -1, log) | |
96 | return testWin | |
97 | ||
98 | #---------------------------------------------------------------------------- | |
99 | ||
100 | ||
101 | overview = """\ | |
102 | <html><body> | |
103 | <h2>wx.Listbook</h2> | |
104 | <p> | |
105 | This class is a control similar to a notebook control, but with a | |
106 | wx.ListCtrl instead of a set of tabs. | |
107 | ||
108 | """ | |
109 | ||
110 | ||
111 | ||
112 | if __name__ == '__main__': | |
113 | import sys,os | |
114 | import run | |
115 | run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:]) | |
116 | ||
117 | ||
118 |