]> git.saurik.com Git - wxWidgets.git/blame_incremental - wxPython/demo/wxNotebook.py
regenerated after adding DEBUG_ options
[wxWidgets.git] / wxPython / demo / wxNotebook.py
... / ...
CommitLineData
1
2from wxPython.wx import *
3
4import ColorPanel
5import GridSimple
6import wxListCtrl
7import wxScrolledWindow
8import images
9
10import sys
11
12#----------------------------------------------------------------------------
13
14class TestNB(wxNotebook):
15 def __init__(self, parent, id, log):
16 wxNotebook.__init__(self, parent, id, style=
17 #wxNB_TOP
18 wxNB_BOTTOM
19 #wxNB_LEFT
20 #wxNB_RIGHT
21 )
22 self.log = log
23
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.",
30 wxPoint(10, 10))
31 st.SetForegroundColour(wxWHITE)
32 st.SetBackgroundColour(wxBLUE)
33
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
44 win = self.makeColorPanel(wxRED)
45 self.AddPage(win, "Red")
46
47 win = wxScrolledWindow.MyCanvas(self)
48 self.AddPage(win, 'ScrolledWindow')
49
50 win = self.makeColorPanel(wxGREEN)
51 self.AddPage(win, "Green")
52
53 win = GridSimple.SimpleGrid(self, log)
54 self.AddPage(win, "Grid")
55
56 win = wxListCtrl.TestListCtrlPanel(self, log)
57 self.AddPage(win, 'List')
58
59 win = self.makeColorPanel(wxCYAN)
60 self.AddPage(win, "Cyan")
61
62## win = self.makeColorPanel(wxWHITE)
63## self.AddPage(win, "White")
64
65## win = self.makeColorPanel(wxBLACK)
66## self.AddPage(win, "Black")
67
68 win = self.makeColorPanel(wxNamedColour('MIDNIGHT BLUE'))
69 self.AddPage(win, "MIDNIGHT BLUE")
70
71 win = self.makeColorPanel(wxNamedColour('INDIAN RED'))
72 self.AddPage(win, "INDIAN RED")
73
74 EVT_NOTEBOOK_PAGE_CHANGED(self, self.GetId(), self.OnPageChanged)
75 EVT_NOTEBOOK_PAGE_CHANGING(self, self.GetId(), self.OnPageChanging)
76
77
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
88 def OnPageChanged(self, event):
89 old = event.GetOldSelection()
90 new = event.GetSelection()
91 sel = self.GetSelection()
92 self.log.write('OnPageChanged, old:%d, new:%d, sel:%d\n' % (old, new, sel))
93 event.Skip()
94
95 def OnPageChanging(self, event):
96 old = event.GetOldSelection()
97 new = event.GetSelection()
98 sel = self.GetSelection()
99 self.log.write('OnPageChanging, old:%d, new:%d, sel:%d\n' % (old, new, sel))
100 event.Skip()
101
102#----------------------------------------------------------------------------
103
104def runTest(frame, nb, log):
105 testWin = TestNB(nb, -1, log)
106 return testWin
107
108#----------------------------------------------------------------------------
109
110
111
112
113overview = """\
114<html><body>
115<h2>wxNotebook</h2>
116<p>
117This class represents a notebook control, which manages multiple
118windows with associated tabs.
119<p>
120To use the class, create a wxNotebook object and call AddPage or
121InsertPage, passing a window to be used as the page. Do not explicitly
122delete the window for a page that is currently managed by wxNotebook.
123
124"""
125
126
127
128if __name__ == '__main__':
129 import sys,os
130 import run
131 run.main(['', os.path.basename(sys.argv[0])])
132
133
134
135
136