]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/wxListbook.py
2 from wxPython
.wx
import *
7 import wxScrolledWindow
12 #----------------------------------------------------------------------------
14 class TestLB(wxListbook
):
15 def __init__(self
, parent
, id, log
):
16 wxListbook
.__init
__(self
, parent
, id, style
=
25 win
= self
.makeColorPanel(wxBLUE
)
26 self
.AddPage(win
, "Blue")
27 st
= wxStaticText(win
.win
, -1,
28 "You can put nearly any type of window here,\n"
29 "and if the platform supports it then the\n"
30 "tabs can be on any side of the notebook.",
32 st
.SetForegroundColour(wxWHITE
)
33 st
.SetBackgroundColour(wxBLUE
)
35 # Show how to put an image on one of the notebook tabs,
36 # first make the image list:
37 il
= wxImageList(16, 16)
38 idx1
= il
.Add(images
.getSmilesBitmap())
39 self
.AssignImageList(il
)
41 # now put an image on the first tab we just created:
42 self
.SetPageImage(0, idx1
)
45 win
= self
.makeColorPanel(wxRED
)
46 self
.AddPage(win
, "Red")
48 win
= wxScrolledWindow
.MyCanvas(self
)
49 self
.AddPage(win
, 'ScrolledWindow')
51 win
= self
.makeColorPanel(wxGREEN
)
52 self
.AddPage(win
, "Green")
54 win
= GridSimple
.SimpleGrid(self
, log
)
55 self
.AddPage(win
, "Grid")
57 win
= wxListCtrl
.TestListCtrlPanel(self
, log
)
58 self
.AddPage(win
, 'List')
60 win
= self
.makeColorPanel(wxCYAN
)
61 self
.AddPage(win
, "Cyan")
63 ## win = self.makeColorPanel(wxWHITE)
64 ## self.AddPage(win, "White")
66 ## win = self.makeColorPanel(wxBLACK)
67 ## self.AddPage(win, "Black")
69 win
= self
.makeColorPanel(wxNamedColour('MIDNIGHT BLUE'))
70 self
.AddPage(win
, "MIDNIGHT BLUE")
72 win
= self
.makeColorPanel(wxNamedColour('INDIAN RED'))
73 self
.AddPage(win
, "INDIAN RED")
75 EVT_LISTBOOK_PAGE_CHANGED(self
, self
.GetId(), self
.OnPageChanged
)
76 EVT_LISTBOOK_PAGE_CHANGING(self
, self
.GetId(), self
.OnPageChanging
)
79 def makeColorPanel(self
, color
):
81 win
= ColorPanel
.ColoredPanel(p
, color
)
83 def OnCPSize(evt
, win
=win
):
84 win
.SetSize(evt
.GetSize())
89 def OnPageChanged(self
, event
):
90 old
= event
.GetOldSelection()
91 new
= event
.GetSelection()
92 sel
= self
.GetSelection()
93 self
.log
.write('OnPageChanged, old:%d, new:%d, sel:%d\n' % (old
, new
, sel
))
96 def OnPageChanging(self
, event
):
97 old
= event
.GetOldSelection()
98 new
= event
.GetSelection()
99 sel
= self
.GetSelection()
100 self
.log
.write('OnPageChanging, old:%d, new:%d, sel:%d\n' % (old
, new
, sel
))
103 #----------------------------------------------------------------------------
105 def runTest(frame
, nb
, log
):
106 testWin
= TestLB(nb
, -1, log
)
109 #----------------------------------------------------------------------------
118 This class is a control similar to a notebook control, but with a
119 wxListCtrl instead of a set of tabs.
125 if __name__
== '__main__':
128 run
.main(['', os
.path
.basename(sys
.argv
[0])])