Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / devtools / v8plus / lib / python2.4 / site-packages / Pmw / Pmw_1_2 / doc / NoteBook.html
CommitLineData
920dae64
AT
1
2 <html>
3 <head>
4 <meta name="description" content="Pmw - a toolkit for building high-level compound widgets in Python">
5 <meta name="content" content="python, megawidget, mega widget, compound widget, gui, tkinter">
6 <title>Pmw.NoteBook reference manual</title>
7 </head>
8
9 <body bgcolor="#ffffff" text="#000000" link="#0000ee"
10 vlink="551a8b" alink="ff0000">
11
12 <h1 ALIGN="CENTER">Pmw.NoteBook</h1>
13
14<center><IMG SRC=NoteBook.gif ALT="" WIDTH=400 HEIGHT=219></center>
15<dl>
16<dt> <h3>Name</h3></dt><dd>
17<p>Pmw.NoteBook() -
18 a set of tabbed pages
19</p>
20
21
22</dd>
23<dt> <h3>Inherits</h3></dt><dd>
24<a href="MegaArchetype.html">Pmw.MegaArchetype</a><br>
25</dd>
26<dt> <h3>Description</h3></dt><dd>
27<p>
28 A notebook contains a set of tabbed pages. At any one time only
29 one of these pages (the <em>selected</em> page) is visible, with the
30 other pages being hidden "beneath" it. Another page in the
31 notebook may be displayed by clicking on the tab attached to the
32 page. The tabs are displayed along the top edge.</p>
33
34<p> Optionally, the notebook may be displayed without tabs. In this
35 case, another selection widget, such as <a href="OptionMenu.html">Pmw.OptionMenu</a>, may be used
36 to select the pages.</p>
37
38<p> This megawidget is derived from <a href="MegaArchetype.html">Pmw.MegaArchetype</a> (not <a href="MegaWidget.html">Pmw.MegaWidget</a>
39 like most other megawidgets), with the hull class being
40 Tkinter.Canvas.</p>
41
42<p></p>
43
44
45</dd>
46<dt> <h3>Options</h3></dt><dd>
47Options for this megawidget and its base
48classes are described below.<p></p>
49<a name=option.arrownavigation></a>
50<dl><dt> <strong>arrownavigation
51</strong></dt><dd>
52Initialisation option. If true and a tab button has the keyboard focus, then the Left and
53 Right arrow keys can be used to select the page before or after
54 the tab button with the focus. The default is <strong>1</strong>.</p>
55
56
57</dd></dl>
58<a name=option.borderwidth></a>
59<dl><dt> <strong>borderwidth
60</strong></dt><dd>
61Initialisation option. The width of the border drawn around each tab and around the
62 selected page. The default is <strong>2</strong>.</p>
63
64
65</dd></dl>
66<a name=option.createcommand></a>
67<dl><dt> <strong>createcommand
68</strong></dt><dd>
69Specifies a function to call when a page is selected for the first
70 time. The function is called with a single argument, which is the
71 name of the selected page, and is called before the <strong>raisecommand</strong>
72 function. This allows the creation of the page contents to be
73 deferred until the page is first displayed. The default is <strong>None</strong>.</p>
74
75
76</dd></dl>
77<a name=option.lowercommand></a>
78<dl><dt> <strong>lowercommand
79</strong></dt><dd>
80Specifies a function to call when the selected page is replaced
81 with a new selected page. The function is called with a single
82 argument, which is the name of the previously selected page, and
83 is called before the <strong>createcommand</strong> or <strong>raisecommand</strong> functions. The default is <strong>None</strong>.</p>
84
85
86</dd></dl>
87<a name=option.pagemargin></a>
88<dl><dt> <strong>pagemargin
89</strong></dt><dd>
90Initialisation option. The margin (in pixels) around the selected page inside the
91 notebook's page border. The default is <strong>4</strong>.</p>
92
93
94</dd></dl>
95<a name=option.raisecommand></a>
96<dl><dt> <strong>raisecommand
97</strong></dt><dd>
98Specifies a function to call when a new page is selected. The
99 function is called with a single argument, which is the name of
100 the selected page. The default is <strong>None</strong>.</p>
101
102
103</dd></dl>
104<a name=option.tabpos></a>
105<dl><dt> <strong>tabpos
106</strong></dt><dd>
107Initialisation option. Specifies the location of the tabs. If <strong>'n'</strong>, tabs are created
108 for each page and positioned at the top of the notebook. If
109 <strong>None</strong>, no tabs are created, in which case another selection
110 widget can be used to select pages by calling the <code>selectpage()</code>
111 method. The default is <strong>'n'</strong>.</p>
112
113
114</dd></dl>
115</dd>
116<dt> <h3>Components</h3></dt><dd>
117Components created by this megawidget and its base
118classes are described below.<p></p>
119<a name=component.hull></a>
120<dl><dt> <strong>hull
121</strong></dt><dd>
122This acts as the body for the megawidget. The contents of the
123 megawidget are created as canvas items and positioned in the
124 hull using the canvas coordinate system. By default, this component is a Tkinter.Canvas.</p>
125
126
127</dd></dl>
128</dd>
129<dt> <h3>Dynamic components</h3></dt><dd>
130<p>
131 Page and tab components are created dynamically by the <code>add()</code>
132 and <code>insert()</code> methods. By default, the pages are of type
133 Tkinter.Frame and are created with a component group of <strong>Page</strong>
134 and the tabs are of type Tkinter.Button and are created with a
135 component group of <strong>Tab</strong>.</p>
136<p> </p>
137
138
139
140</dd>
141<a name=methods></a>
142<dt> <h3>Methods</h3></dt><dd>
143Only methods specific to this megawidget are described below.
144For a description of its inherited methods, see the
145manual for its base class
146<strong><a href="MegaArchetype.html#methods">Pmw.MegaArchetype</a></strong>.
147In addition, methods from the
148<strong>Tkinter.Canvas</strong> class
149are forwarded by this megawidget to the
150<strong>hull</strong> component.
151<p></p>
152<a name=method.add></a>
153<dl><dt> <strong>add</strong>(<em>pageName</em>, **<em>kw</em>)</dt><dd>
154Add a page at the end of the notebook. See the <code>insert()</code> method
155 for full details.</p>
156
157
158</dd></dl>
159<a name=method.delete></a>
160<dl><dt> <strong>delete</strong>(*<em>pageNames</em>)</dt><dd>
161Delete the pages given by <em>pageNames</em> from the notebook. Each of
162 the <em>pageNames</em> may have any of the forms accepted by the
163 <code>index()</code> method.</p>
164<p> If the currently selected page is deleted, then the next page, in
165 index order, is selected. If the <strong>end</strong> page is deleted, then the
166 previous page is selected.</p>
167
168
169
170</dd></dl>
171<a name=method.getcurselection></a>
172<dl><dt> <strong>getcurselection</strong>()</dt><dd>
173Return the name of the currently selected page.</p>
174
175
176</dd></dl>
177<a name=method.index></a>
178<dl><dt> <strong>index</strong>(<em>index</em>, <em>forInsert</em> = <strong>0</strong>)</dt><dd>
179Return the numerical index of the page corresponding to <em>index</em>.
180 This may be specified in any of the following forms:</p>
181<dl><dt><em>name</em></dt><dd>Specifies the page labelled <em>name</em>.<p></p>
182
183</dd>
184<dt><em>number</em></dt><dd>Specifies the page numerically, where <strong>0</strong> corresponds to
185 the first page.<p></p>
186
187</dd>
188<dt><strong>Pmw.END</strong></dt><dd>Specifies the last page.<p></p>
189
190</dd>
191<dt><strong>Pmw.SELECT</strong></dt><dd>Specifies the currently selected page.<p></p>
192
193</dd></dl>
194<p> If <em>forInsert</em> is true, <strong>Pmw.END</strong> returns the number of pages
195 rather than the index of the last page.</p>
196
197
198
199</dd></dl>
200<a name=method.insert></a>
201<dl><dt> <strong>insert</strong>(<em>pageName</em>, <em>before</em> = <strong>0</strong>, **<em>kw</em>)</dt><dd>
202Add a page to the notebook as a component named <em>pageName</em>. The
203 page is added just before the page specified by <em>before</em>, which
204 may have any of the forms accepted by the <code>index()</code> method. If
205 <strong>tabpos</strong> is not <strong>None</strong>, also create a tab as a component named
206 <em>pageName</em>-<strong>tab</strong>. Keyword arguments prefixed with <strong>page_</strong> or
207 <strong>tab_</strong> are passed to the respective constructors when creating the
208 page or tab. If the <strong>tab_text</strong> keyword argument is not given, the
209 <strong>text</strong> option of the tab defaults to <em>pageName</em>. If a page is
210 inserted into an empty notebook, the page is selected. To add a
211 page to the end of the notebook, use <code>add()</code>. The method returns
212 the <em>pageName</em> component widget.</p>
213
214
215</dd></dl>
216<a name=method.nextpage></a>
217<dl><dt> <strong>nextpage</strong>(<em>pageIndex</em> = <strong>None</strong>)</dt><dd>
218If <em>pageIndex</em> is <strong>None</strong>, then select the page after the
219 currently selected page. Otherwise select the page after
220 <em>pageIndex</em>, which may have any of the forms accepted by the
221 <code>index()</code> method.</p>
222
223
224</dd></dl>
225<a name=method.page></a>
226<dl><dt> <strong>page</strong>(<em>pageIndex</em>)</dt><dd>
227Return the frame component widget of the page <em>pageIndex</em>, where
228 <em>pageIndex</em> may have any of the forms accepted by the <code>index()</code>
229 method.</p>
230
231
232</dd></dl>
233<a name=method.pagenames></a>
234<dl><dt> <strong>pagenames</strong>()</dt><dd>
235Return a list of the names of the pages, in display order.</p>
236
237
238</dd></dl>
239<a name=method.previouspage></a>
240<dl><dt> <strong>previouspage</strong>(<em>pageIndex</em> = <strong>None</strong>)</dt><dd>
241If <em>pageIndex</em> is <strong>None</strong>, then select the page before the
242 currently selected page. Otherwise select the page before
243 <em>pageIndex</em>, which may have any of the forms accepted by the
244 <code>index()</code> method.</p>
245
246
247</dd></dl>
248<a name=method.recolorborders></a>
249<dl><dt> <strong>recolorborders</strong>()</dt><dd>
250Change the color of the page and tab borders. This method is
251 required because the borders are created as canvas polygons and
252 hence do not respond to normal color changing techniques, such as
253 <code>Pmw.Color.changecolor()</code>.</p>
254
255
256</dd></dl>
257<a name=method.selectpage></a>
258<dl><dt> <strong>selectpage</strong>(<em>page</em>)</dt><dd>
259Select <em>page</em> to be the currently selected page. The page will be
260 raised and the previous selected page will be lowered.</p>
261
262
263</dd></dl>
264<a name=method.setnaturalsize></a>
265<dl><dt> <strong>setnaturalsize</strong>(<em>pageNames</em> = <strong>None</strong>)</dt><dd>
266Set the width and height of the notebook to be the maximum
267 requested width and height of the pages specified by <em>pageNames</em>.
268 If <em>pageNames</em> is <strong>None</strong>, the size of all pages are used to
269 determine the size of the notebook. Otherwise, <em>pageNames</em> must
270 be a list of page names whose sizes are to be used to determine
271 the size of the notebook. This method should be called after all
272 pages and their contents have been created. It calls
273 <code>update_idletasks()</code> so that the width and height of the pages can
274 be determined. This may cause the notebook to flash onto the
275 screen at the default size before resizing to the natural size.</p>
276
277
278</dd></dl>
279<a name=method.tab></a>
280<dl><dt> <strong>tab</strong>(<em>pageIndex</em>)</dt><dd>
281Return the tab component widget of the page <em>pageIndex</em>, where
282 <em>pageIndex</em> may have any of the forms accepted by the <code>index()</code>
283 method. If <strong>tabpos</strong> is <strong>None</strong>, return <strong>None</strong>.</p>
284
285
286</dd></dl>
287</dd>
288<dt> <h3>Example</h3></dt><dd>
289The image at the top of this manual is a snapshot
290of the window (or part of the window) produced
291by the following code.<p></p>
292<pre>
293class Demo:
294 def __init__(self, parent):
295 # Create and pack the NoteBook.
296 notebook = Pmw.NoteBook(parent)
297 notebook.pack(fill = 'both', expand = 1, padx = 10, pady = 10)
298
299 # Add the "Appearance" page to the notebook.
300 page = notebook.add('Appearance')
301 notebook.tab('Appearance').focus_set()
302
303 # Create the "Toolbar" contents of the page.
304 group = Pmw.Group(page, tag_text = 'Toolbar')
305 group.pack(fill = 'both', expand = 1, padx = 10, pady = 10)
306 b1 = Tkinter.Checkbutton(group.interior(), text = 'Show toolbar')
307 b1.grid(row = 0, column = 0)
308 b2 = Tkinter.Checkbutton(group.interior(), text = 'Toolbar tips')
309 b2.grid(row = 0, column = 1)
310
311 # Create the "Startup" contents of the page.
312 group = Pmw.Group(page, tag_text = 'Startup')
313 group.pack(fill = 'both', expand = 1, padx = 10, pady = 10)
314 home = Pmw.EntryField(group.interior(), labelpos = 'w',
315 label_text = 'Home page location:')
316 home.pack(fill = 'x', padx = 20, pady = 10)
317
318 # Add two more empty pages.
319 page = notebook.add('Helpers')
320 page = notebook.add('Images')
321
322 notebook.setnaturalsize()
323
324</pre>
325</dd>
326</dl>
327
328 <center><P ALIGN="CENTER">
329 <IMG SRC = blue_line.gif ALT = "" WIDTH=320 HEIGHT=5>
330 </p></center>
331
332
333 <font size=-1>
334 <center><P ALIGN="CENTER">
335 Pmw 1.2 -
336 5 Aug 2003
337 - <a href="index.html">Home</a>
338 <br>Manual page last reviewed: 30 October 1999
339 </p></center>
340 </font>
341
342 </body>
343 </html>
344