]> git.saurik.com Git - wxWidgets.git/blame - wxPython/demo/wxListbook.py
New wxDesigner-less version of the MimeTypesManager demo
[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
372bde9b
RD
14import images
15
16import ColorPanel
17
fbd5dd1d
RD
18colourList = [ "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 ]
2f0f3b0f
RD
34
35#----------------------------------------------------------------------------
36
8fa876ca 37class TestLB(wx.Listbook):
2f0f3b0f 38 def __init__(self, parent, id, log):
8fa876ca
RD
39 wx.Listbook.__init__(self, parent, id, style=
40 wx.LB_DEFAULT
2f0f3b0f
RD
41 #wxLB_TOP
42 #wxLB_BOTTOM
43 #wxLB_LEFT
44 #wxLB_RIGHT
45 )
46 self.log = log
47
2f0f3b0f 48
fbd5dd1d 49 # make an image list using the BlomXX images
372bde9b 50 il = wx.ImageList(32, 32)
fbd5dd1d
RD
51 for x in range(1, 15):
52 f = getattr(images, 'getBlom%02dBitmap' % x)
53 bmp = f()
54 il.Add(bmp)
2f0f3b0f 55 self.AssignImageList(il)
fbd5dd1d
RD
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:
372bde9b 66 st = wx.StaticText(win.win, -1,
fbd5dd1d
RD
67 "You can put nearly any type of window here,\n"
68 "and the list can be on any side of the Listbook",
372bde9b 69 wx.Point(10, 10))
fbd5dd1d
RD
70 #st.SetForegroundColour(wxWHITE)
71 #st.SetBackgroundColour(wxBLUE)
72 first = False
73
74
2f0f3b0f 75
372bde9b
RD
76 wx.EVT_LISTBOOK_PAGE_CHANGED(self, self.GetId(), self.OnPageChanged)
77 wx.EVT_LISTBOOK_PAGE_CHANGING(self, self.GetId(), self.OnPageChanging)
2f0f3b0f
RD
78
79
80 def makeColorPanel(self, color):
8fa876ca 81 p = wx.Panel(self, -1)
2f0f3b0f
RD
82 win = ColorPanel.ColoredPanel(p, color)
83 p.win = win
84 def OnCPSize(evt, win=win):
85 win.SetSize(evt.GetSize())
8fa876ca 86 p.Bind(wx.EVT_SIZE, OnCPSize)
2f0f3b0f
RD
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
106def runTest(frame, nb, log):
107 testWin = TestLB(nb, -1, log)
108 return testWin
109
110#----------------------------------------------------------------------------
111
112
2f0f3b0f
RD
113overview = """\
114<html><body>
115<h2>wxListbook</h2>
116<p>
117This class is a control similar to a notebook control, but with a
118wxListCtrl instead of a set of tabs.
119
120"""
121
122
123
124if __name__ == '__main__':
125 import sys,os
126 import run
127 run.main(['', os.path.basename(sys.argv[0])])
128
129