]> git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/wxNotebook.py
FileDlg updates.
[wxWidgets.git] / wxPython / demo / wxNotebook.py
1
2 from wxPython.wx import *
3
4 import ColorPanel
5 import GridSimple
6 import wxListCtrl
7 import wxScrolledWindow
8
9 import sys
10
11 #----------------------------------------------------------------------------
12
13 class TestNB(wxNotebook):
14 def __init__(self, parent, id, log):
15 wxNotebook.__init__(self, parent, id, style=wxNB_BOTTOM)
16 self.log = log
17
18
19 win = self.makeColorPanel(wxBLUE)
20 self.AddPage(win, "Blue")
21 st = wxStaticText(win.win, -1,
22 "You can put nearly any type of window here,\n"
23 "and if the platform supports it then the\n"
24 "tabs can be on any side of the notebook.",
25 wxPoint(10, 10))
26 st.SetForegroundColour(wxWHITE)
27 st.SetBackgroundColour(wxBLUE)
28
29 win = self.makeColorPanel(wxRED)
30 self.AddPage(win, "Red")
31
32 win = wxScrolledWindow.MyCanvas(self)
33 self.AddPage(win, 'ScrolledWindow')
34
35 win = self.makeColorPanel(wxGREEN)
36 self.AddPage(win, "Green")
37
38 win = GridSimple.SimpleGrid(self, log)
39 self.AddPage(win, "Grid")
40
41 win = wxListCtrl.TestListCtrlPanel(self, log)
42 self.AddPage(win, 'List')
43
44 win = self.makeColorPanel(wxCYAN)
45 self.AddPage(win, "Cyan")
46
47 win = self.makeColorPanel(wxWHITE)
48 self.AddPage(win, "White")
49
50 win = self.makeColorPanel(wxBLACK)
51 self.AddPage(win, "Black")
52
53 win = self.makeColorPanel(wxNamedColour('MIDNIGHT BLUE'))
54 self.AddPage(win, "MIDNIGHT BLUE")
55
56 win = self.makeColorPanel(wxNamedColour('INDIAN RED'))
57 self.AddPage(win, "INDIAN RED")
58
59 EVT_NOTEBOOK_PAGE_CHANGED(self, self.GetId(), self.OnPageChanged)
60 EVT_NOTEBOOK_PAGE_CHANGING(self, self.GetId(), self.OnPageChanging)
61
62
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
73 def OnPageChanged(self, event):
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))
83 event.Skip()
84
85
86 #----------------------------------------------------------------------------
87
88 def runTest(frame, nb, log):
89 testWin = TestNB(nb, -1, log)
90 return testWin
91
92 #----------------------------------------------------------------------------
93
94
95
96
97
98
99
100
101
102
103
104
105 overview = """\
106 This class represents a notebook control, which manages multiple windows with associated tabs.
107
108 To 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
110 """
111
112
113 if __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