]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/wxNotebook.py
2 from wxPython
.wx
import *
7 import wxScrolledWindow
12 #----------------------------------------------------------------------------
14 class TestNB(wxNotebook
):
15 def __init__(self
, parent
, id, log
):
16 wxNotebook
.__init
__(self
, parent
, id, style
=
24 win
= self
.makeColorPanel(wxBLUE
)
25 self
.AddPage(win
, "Blue")
26 st
= wxStaticText(win
.win
, -1,
27 "You can put nearly any type of window here,\n"
28 "and if the platform supports it then the\n"
29 "tabs can be on any side of the notebook.",
31 st
.SetForegroundColour(wxWHITE
)
32 st
.SetBackgroundColour(wxBLUE
)
34 # Show how to put an image on one of the notebook tabs,
35 # first make the image list:
36 il
= wxImageList(16, 16)
37 idx1
= il
.Add(images
.getSmilesBitmap())
38 self
.AssignImageList(il
)
40 # now put an image on the first tab we just created:
41 self
.SetPageImage(0, idx1
)
44 win
= self
.makeColorPanel(wxRED
)
45 self
.AddPage(win
, "Red")
47 win
= wxScrolledWindow
.MyCanvas(self
)
48 self
.AddPage(win
, 'ScrolledWindow')
50 win
= self
.makeColorPanel(wxGREEN
)
51 self
.AddPage(win
, "Green")
53 win
= GridSimple
.SimpleGrid(self
, log
)
54 self
.AddPage(win
, "Grid")
56 win
= wxListCtrl
.TestListCtrlPanel(self
, log
)
57 self
.AddPage(win
, 'List')
59 win
= self
.makeColorPanel(wxCYAN
)
60 self
.AddPage(win
, "Cyan")
62 win
= self
.makeColorPanel(wxWHITE
)
63 self
.AddPage(win
, "White")
65 win
= self
.makeColorPanel(wxBLACK
)
66 self
.AddPage(win
, "Black")
68 win
= self
.makeColorPanel(wxNamedColour('MIDNIGHT BLUE'))
69 self
.AddPage(win
, "MIDNIGHT BLUE")
71 win
= self
.makeColorPanel(wxNamedColour('INDIAN RED'))
72 self
.AddPage(win
, "INDIAN RED")
74 EVT_NOTEBOOK_PAGE_CHANGED(self
, self
.GetId(), self
.OnPageChanged
)
75 EVT_NOTEBOOK_PAGE_CHANGING(self
, self
.GetId(), self
.OnPageChanging
)
78 def makeColorPanel(self
, color
):
80 win
= ColorPanel
.ColoredPanel(p
, color
)
82 def OnCPSize(evt
, win
=win
):
83 win
.SetSize(evt
.GetSize())
88 def OnPageChanged(self
, event
):
89 old
= event
.GetOldSelection()
90 new
= event
.GetSelection()
91 self
.log
.write('OnPageChanged, old:%d, new:%d\n' % (old
, new
))
94 def OnPageChanging(self
, event
):
95 old
= event
.GetOldSelection()
96 new
= event
.GetSelection()
97 self
.log
.write('OnPageChanging, old:%d, new:%d\n' % (old
, new
))
101 #----------------------------------------------------------------------------
103 def runTest(frame
, nb
, log
):
104 testWin
= TestNB(nb
, -1, log
)
107 #----------------------------------------------------------------------------
116 This class represents a notebook control, which manages multiple
117 windows with associated tabs.
119 To use the class, create a wxNotebook object and call AddPage or
120 InsertPage, passing a window to be used as the page. Do not explicitly
121 delete the window for a page that is currently managed by wxNotebook.
127 if __name__
== '__main__':
130 run
.main(['', os
.path
.basename(sys
.argv
[0])])