]> git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/wxNotebook.py
digital mars updated
[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 import images
9
10 import sys
11
12 #----------------------------------------------------------------------------
13
14 class TestNB(wxNotebook):
15 def __init__(self, parent, id, log):
16 wxNotebook.__init__(self, parent, id, style=
17 #0
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 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))
98 event.Skip()
99
100
101 #----------------------------------------------------------------------------
102
103 def runTest(frame, nb, log):
104 testWin = TestNB(nb, -1, log)
105 return testWin
106
107 #----------------------------------------------------------------------------
108
109
110
111
112 overview = """\
113 <html><body>
114 <h2>wxNotebook</h2>
115 <p>
116 This class represents a notebook control, which manages multiple
117 windows with associated tabs.
118 <p>
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.
122
123 """
124
125
126
127 if __name__ == '__main__':
128 import sys,os
129 import run
130 run.main(['', os.path.basename(sys.argv[0])])
131
132
133
134
135