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