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