]> git.saurik.com Git - wxWidgets.git/blame - wxPython/demo/wxNotebook.py
tried to make Close() docs more clear
[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
cf694132 8
dfef5d51
RD
9import sys
10
cf694132
RD
11#----------------------------------------------------------------------------
12
eec92d76
RD
13class TestNB(wxNotebook):
14 def __init__(self, parent, id, log):
15 wxNotebook.__init__(self, parent, id, style=wxNB_BOTTOM)
16 self.log = log
cf694132 17
afcb7fb8
RD
18
19 win = self.makeColorPanel(wxBLUE)
eec92d76 20 self.AddPage(win, "Blue")
afcb7fb8 21 st = wxStaticText(win.win, -1,
eec92d76 22 "You can put nearly any type of window here,\n"
eb0f373c
RD
23 "and if the platform supports it then the\n"
24 "tabs can be on any side of the notebook.",
eec92d76
RD
25 wxPoint(10, 10))
26 st.SetForegroundColour(wxWHITE)
27 st.SetBackgroundColour(wxBLUE)
cf694132 28
afcb7fb8 29 win = self.makeColorPanel(wxRED)
eec92d76 30 self.AddPage(win, "Red")
cf694132 31
eec92d76
RD
32 win = wxScrolledWindow.MyCanvas(self)
33 self.AddPage(win, 'ScrolledWindow')
cf694132 34
afcb7fb8 35 win = self.makeColorPanel(wxGREEN)
eec92d76 36 self.AddPage(win, "Green")
f0261a72 37
f6bcfd97 38 win = GridSimple.SimpleGrid(self, log)
eec92d76 39 self.AddPage(win, "Grid")
cf694132 40
eec92d76
RD
41 win = wxListCtrl.TestListCtrlPanel(self, log)
42 self.AddPage(win, 'List')
f0261a72 43
afcb7fb8 44 win = self.makeColorPanel(wxCYAN)
eec92d76 45 self.AddPage(win, "Cyan")
f0261a72 46
afcb7fb8 47 win = self.makeColorPanel(wxWHITE)
eec92d76 48 self.AddPage(win, "White")
cf694132 49
afcb7fb8 50 win = self.makeColorPanel(wxBLACK)
eec92d76 51 self.AddPage(win, "Black")
cf694132 52
afcb7fb8 53 win = self.makeColorPanel(wxNamedColour('MIDNIGHT BLUE'))
eec92d76 54 self.AddPage(win, "MIDNIGHT BLUE")
cf694132 55
afcb7fb8 56 win = self.makeColorPanel(wxNamedColour('INDIAN RED'))
eec92d76 57 self.AddPage(win, "INDIAN RED")
cf694132 58
eec92d76 59 EVT_NOTEBOOK_PAGE_CHANGED(self, self.GetId(), self.OnPageChanged)
3bd1e033 60 EVT_NOTEBOOK_PAGE_CHANGING(self, self.GetId(), self.OnPageChanging)
cf694132 61
cf694132 62
afcb7fb8
RD
63 def makeColorPanel(self, color):
64 p = wxPanel(self, -1)
65 win = ColorPanel.ColoredPanel(p, color)
66 p.win = win
67 def OnCPSize(evt, win=win):
68 win.SetSize(evt.GetSize())
69 EVT_SIZE(p, OnCPSize)
70 return p
71
72
eec92d76 73 def OnPageChanged(self, event):
3bd1e033
RD
74 old = event.GetOldSelection()
75 new = event.GetSelection()
76 self.log.write('OnPageChanged, old:%d, new:%d\n' % (old, new))
77 event.Skip()
78
79 def OnPageChanging(self, event):
80 old = event.GetOldSelection()
81 new = event.GetSelection()
82 self.log.write('OnPageChanging, old:%d, new:%d\n' % (old, new))
eec92d76 83 event.Skip()
cf694132
RD
84
85
eec92d76 86#----------------------------------------------------------------------------
cf694132 87
eec92d76
RD
88def runTest(frame, nb, log):
89 testWin = TestNB(nb, -1, log)
90 return testWin
91
92#----------------------------------------------------------------------------
cf694132
RD
93
94
95
96
97
98
99
100
101
102
103
104
105overview = """\
106This class represents a notebook control, which manages multiple windows with associated tabs.
107
108To use the class, create a wxNotebook object and call AddPage or InsertPage, passing a window to be used as the page. Do not explicitly delete the window for a page that is currently managed by wxNotebook.
109
cf694132 110"""
dfef5d51
RD
111
112
113if __name__ == "__main__":
114 app = wxPySimpleApp()
115 frame = wxFrame(None, -1, "Test Notebook", size=(600, 400))
116 win = TestNB(frame, -1, sys.stdout)
117 frame.Show(true)
118 app.MainLoop()
119
120
121