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