1 # 11/20/2003 - Jeff Grimmett (grimmtooth@softhome.net)
3 # o Updated for wx namespace
16 #----------------------------------------------------------------------------
18 class TestNB(wx
.Notebook
):
19 def __init__(self
, parent
, id, log
):
20 wx
.Notebook
.__init
__(self
, parent
, id, style
=
28 win
= self
.makeColorPanel(wx
.BLUE
)
29 self
.AddPage(win
, "Blue")
30 st
= wx
.StaticText(win
.win
, -1,
31 "You can put nearly any type of window here,\n"
32 "and if the platform supports it then the\n"
33 "tabs can be on any side of the notebook.",
36 st
.SetForegroundColour(wx
.WHITE
)
37 st
.SetBackgroundColour(wx
.BLUE
)
39 # Show how to put an image on one of the notebook tabs,
40 # first make the image list:
41 il
= wx
.ImageList(16, 16)
42 idx1
= il
.Add(images
.getSmilesBitmap())
43 self
.AssignImageList(il
)
45 # now put an image on the first tab we just created:
46 self
.SetPageImage(0, idx1
)
49 win
= self
.makeColorPanel(wx
.RED
)
50 self
.AddPage(win
, "Red")
52 win
= ScrolledWindow
.MyCanvas(self
)
53 self
.AddPage(win
, 'ScrolledWindow')
55 win
= self
.makeColorPanel(wx
.GREEN
)
56 self
.AddPage(win
, "Green")
58 win
= GridSimple
.SimpleGrid(self
, log
)
59 self
.AddPage(win
, "Grid")
61 win
= ListCtrl
.TestListCtrlPanel(self
, log
)
62 self
.AddPage(win
, 'List')
64 win
= self
.makeColorPanel(wx
.CYAN
)
65 self
.AddPage(win
, "Cyan")
67 # win = self.makeColorPanel(wxWHITE)
68 # self.AddPage(win, "White")
70 # win = self.makeColorPanel(wxBLACK)
71 # self.AddPage(win, "Black")
73 win
= self
.makeColorPanel(wx
.NamedColour('MIDNIGHT BLUE'))
74 self
.AddPage(win
, "MIDNIGHT BLUE")
76 win
= self
.makeColorPanel(wx
.NamedColour('INDIAN RED'))
77 self
.AddPage(win
, "INDIAN RED")
79 self
.Bind(wx
.EVT_NOTEBOOK_PAGE_CHANGED
, self
.OnPageChanged
)
80 self
.Bind(wx
.EVT_NOTEBOOK_PAGE_CHANGING
, self
.OnPageChanging
)
83 def makeColorPanel(self
, color
):
84 p
= wx
.Panel(self
, -1)
85 win
= ColorPanel
.ColoredPanel(p
, color
)
88 def OnCPSize(evt
, win
=win
):
89 win
.SetSize(evt
.GetSize())
91 p
.Bind(wx
.EVT_SIZE
, OnCPSize
)
94 def OnPageChanged(self
, event
):
95 old
= event
.GetOldSelection()
96 new
= event
.GetSelection()
97 sel
= self
.GetSelection()
98 self
.log
.write('OnPageChanged, old:%d, new:%d, sel:%d\n' % (old
, new
, sel
))
101 def OnPageChanging(self
, event
):
102 old
= event
.GetOldSelection()
103 new
= event
.GetSelection()
104 sel
= self
.GetSelection()
105 self
.log
.write('OnPageChanging, old:%d, new:%d, sel:%d\n' % (old
, new
, sel
))
108 #----------------------------------------------------------------------------
110 def runTest(frame
, nb
, log
):
111 testWin
= TestNB(nb
, -1, log
)
114 #----------------------------------------------------------------------------
121 This class represents a notebook control, which manages multiple
122 windows with associated tabs.
124 To use the class, create a wxNotebook object and call AddPage or
125 InsertPage, passing a window to be used as the page. Do not explicitly
126 delete the window for a page that is currently managed by wxNotebook.
131 if __name__
== '__main__':
134 run
.main(['', os
.path
.basename(sys
.argv
[0])])