]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/wxListbook.py
1 # 11/22/2003 - Jeff Grimmett (grimmtooth@softhome.net)
3 # o Updated for wx namespace
5 # 11/29/2003 - Jeff Grimmett (grimmtooth@softhome.net)
7 # o Bunches of imports that might need to go away for the final roll-out.
14 colourList
= [ "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",
31 #----------------------------------------------------------------------------
33 class TestLB(wx
.Listbook
):
34 def __init__(self
, parent
, id, log
):
35 wx
.Listbook
.__init
__(self
, parent
, id, style
=
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
)
51 self
.AssignImageList(il
)
53 # Now make a bunch of panels for the list book
56 for colour
in colourList
:
57 win
= self
.makeColorPanel(colour
)
58 self
.AddPage(win
, colour
, imageId
=imID
)
60 if imID
== il
.GetImageCount(): imID
= 0
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",
66 #st.SetForegroundColour(wxWHITE)
67 #st.SetBackgroundColour(wxBLUE)
72 EVT_LISTBOOK_PAGE_CHANGED(self
, self
.GetId(), self
.OnPageChanged
)
73 EVT_LISTBOOK_PAGE_CHANGING(self
, self
.GetId(), self
.OnPageChanging
)
76 def makeColorPanel(self
, color
):
77 p
= wx
.Panel(self
, -1)
78 win
= ColorPanel
.ColoredPanel(p
, color
)
80 def OnCPSize(evt
, win
=win
):
81 win
.SetSize(evt
.GetSize())
82 p
.Bind(wx
.EVT_SIZE
, OnCPSize
)
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
))
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
))
100 #----------------------------------------------------------------------------
102 def runTest(frame
, nb
, log
):
103 testWin
= TestLB(nb
, -1, log
)
106 #----------------------------------------------------------------------------
113 This class is a control similar to a notebook control, but with a
114 wxListCtrl instead of a set of tabs.
120 if __name__
== '__main__':
123 run
.main(['', os
.path
.basename(sys
.argv
[0])])