]> git.saurik.com Git - wxWidgets.git/blame - wxPython/demo/wxNotebook.py
Removed deprecation warnings in OGL and Gizmos
[wxWidgets.git] / wxPython / demo / wxNotebook.py
CommitLineData
cf694132
RD
1
2from wxPython.wx import *
f0261a72 3
cf694132 4import ColorPanel
f6bcfd97 5import GridSimple
f0261a72
RD
6import wxListCtrl
7import wxScrolledWindow
1e4a197e 8import images
cf694132 9
dfef5d51
RD
10import sys
11
cf694132
RD
12#----------------------------------------------------------------------------
13
eec92d76
RD
14class TestNB(wxNotebook):
15 def __init__(self, parent, id, log):
1e4a197e
RD
16 wxNotebook.__init__(self, parent, id, style=
17 #0
18 wxNB_BOTTOM
19 #wxNB_LEFT
20 #wxNB_RIGHT
21 )
eec92d76 22 self.log = log
cf694132 23
afcb7fb8 24 win = self.makeColorPanel(wxBLUE)
eec92d76 25 self.AddPage(win, "Blue")
afcb7fb8 26 st = wxStaticText(win.win, -1,
eec92d76 27 "You can put nearly any type of window here,\n"
eb0f373c
RD
28 "and if the platform supports it then the\n"
29 "tabs can be on any side of the notebook.",
eec92d76
RD
30 wxPoint(10, 10))
31 st.SetForegroundColour(wxWHITE)
32 st.SetBackgroundColour(wxBLUE)
cf694132 33
1e4a197e
RD
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)
39
40 # now put an image on the first tab we just created:
41 self.SetPageImage(0, idx1)
42
43
afcb7fb8 44 win = self.makeColorPanel(wxRED)
eec92d76 45 self.AddPage(win, "Red")
cf694132 46
eec92d76
RD
47 win = wxScrolledWindow.MyCanvas(self)
48 self.AddPage(win, 'ScrolledWindow')
cf694132 49
afcb7fb8 50 win = self.makeColorPanel(wxGREEN)
eec92d76 51 self.AddPage(win, "Green")
f0261a72 52
f6bcfd97 53 win = GridSimple.SimpleGrid(self, log)
eec92d76 54 self.AddPage(win, "Grid")
cf694132 55
eec92d76
RD
56 win = wxListCtrl.TestListCtrlPanel(self, log)
57 self.AddPage(win, 'List')
f0261a72 58
afcb7fb8 59 win = self.makeColorPanel(wxCYAN)
eec92d76 60 self.AddPage(win, "Cyan")
f0261a72 61
afcb7fb8 62 win = self.makeColorPanel(wxWHITE)
eec92d76 63 self.AddPage(win, "White")
cf694132 64
afcb7fb8 65 win = self.makeColorPanel(wxBLACK)
eec92d76 66 self.AddPage(win, "Black")
cf694132 67
afcb7fb8 68 win = self.makeColorPanel(wxNamedColour('MIDNIGHT BLUE'))
eec92d76 69 self.AddPage(win, "MIDNIGHT BLUE")
cf694132 70
afcb7fb8 71 win = self.makeColorPanel(wxNamedColour('INDIAN RED'))
eec92d76 72 self.AddPage(win, "INDIAN RED")
cf694132 73
eec92d76 74 EVT_NOTEBOOK_PAGE_CHANGED(self, self.GetId(), self.OnPageChanged)
3bd1e033 75 EVT_NOTEBOOK_PAGE_CHANGING(self, self.GetId(), self.OnPageChanging)
cf694132 76
cf694132 77
afcb7fb8
RD
78 def makeColorPanel(self, color):
79 p = wxPanel(self, -1)
80 win = ColorPanel.ColoredPanel(p, color)
81 p.win = win
82 def OnCPSize(evt, win=win):
83 win.SetSize(evt.GetSize())
84 EVT_SIZE(p, OnCPSize)
85 return p
86
87
eec92d76 88 def OnPageChanged(self, event):
3bd1e033
RD
89 old = event.GetOldSelection()
90 new = event.GetSelection()
91 self.log.write('OnPageChanged, old:%d, new:%d\n' % (old, new))
92 event.Skip()
93
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))
eec92d76 98 event.Skip()
cf694132
RD
99
100
eec92d76 101#----------------------------------------------------------------------------
cf694132 102
eec92d76
RD
103def runTest(frame, nb, log):
104 testWin = TestNB(nb, -1, log)
105 return testWin
106
107#----------------------------------------------------------------------------
cf694132
RD
108
109
110
111
1e4a197e
RD
112overview = """\
113<html><body>
114<h2>wxNotebook</h2>
115<p>
116This class represents a notebook control, which manages multiple
117windows with associated tabs.
118<p>
119To use the class, create a wxNotebook object and call AddPage or
120InsertPage, passing a window to be used as the page. Do not explicitly
121delete the window for a page that is currently managed by wxNotebook.
cf694132 122
1e4a197e 123"""
cf694132
RD
124
125
126
1e4a197e
RD
127if __name__ == '__main__':
128 import sys,os
129 import run
130 run.main(['', os.path.basename(sys.argv[0])])
cf694132
RD
131
132
133
134
dfef5d51 135