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