Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / devtools / v8plus / lib / python2.4 / site-packages / Pmw / Pmw_1_2 / doc / PanedWidget.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.PanedWidget 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.PanedWidget</h1>
13
14<center><IMG SRC=PanedWidget.gif ALT="" WIDTH=400 HEIGHT=128></center>
15<dl>
16<dt> <h3>Name</h3></dt><dd>
17<p>Pmw.PanedWidget() -
18 frame subdivided into several resizable panes
19</p>
20
21
22</dd>
23<dt> <h3>Inherits</h3></dt><dd>
24<a href="MegaWidget.html">Pmw.MegaWidget</a><br>
25</dd>
26<dt> <h3>Description</h3></dt><dd>
27<p>
28 A paned widget is a container megawidget which manages a number of
29 resizable frames, known as panes. Each pane may act as the container for
30 other widgets. The user may interactively resize the panes by
31 dragging a small rectangle (the handle) or the line between the
32 panes (the separator). The panes may be arranged horizontally or
33 vertically. Each pane may have maximum and minimum limits of its
34 size.</p>
35
36<p></p>
37
38
39</dd>
40<dt> <h3>Options</h3></dt><dd>
41Options for this megawidget and its base
42classes are described below.<p></p>
43<a name=option.command></a>
44<dl><dt> <strong>command
45</strong></dt><dd>
46Specifies a function to be called whenever the size of any of the
47 panes changes. The function is called with a single argument,
48 being a list of the sizes of the panes, in order. For <strong>vertical</strong>
49 orientation, the size is the height of the panes. For
50 <strong>horizontal</strong> orientation, the size is the width of the panes. The default is <strong>None</strong>.</p>
51
52
53</dd></dl>
54<a name=option.handlesize></a>
55<dl><dt> <strong>handlesize
56</strong></dt><dd>
57Initialisation option. Specifies the size in pixels of the square handle which appears on
58 the lines separating the panes. The default is <strong>8</strong>.</p>
59
60
61</dd></dl>
62<a name=option.orient></a>
63<dl><dt> <strong>orient
64</strong></dt><dd>
65Initialisation option. Specifies the orientation of the paned widget. This may be
66 <strong>'horizontal'</strong> or <strong>'vertical'</strong>. If <strong>'vertical'</strong>, the panes are
67 stacked above and below each other, otherwise the panes are laid
68 out side by side. The default is <strong>'vertical'</strong>.</p>
69
70
71</dd></dl>
72<a name=option.separatorrelief></a>
73<dl><dt> <strong>separatorrelief
74</strong></dt><dd>
75Initialisation option. Specifies the relief of the lines separating the panes. The default is <strong>'sunken'</strong>.</p>
76
77
78</dd></dl>
79<a name=option.separatorthickness></a>
80<dl><dt> <strong>separatorthickness
81</strong></dt><dd>
82Initialisation option. Specifies the thickness of the lines separating the panes. The default is <strong>2</strong>.</p>
83
84
85</dd></dl>
86</dd>
87<dt> <h3>Pane options</h3></dt><dd>
88<p>
89 Each pane has the following options. These may be set when
90 creating or configuring a pane. The value of each option may
91 be an integer, which specifies a pane size in pixels, or a
92 real number between 0.0 and 1.0, which specifies a pane size
93 proportional to the size of the entire paned widget.</p>
94
95<dl><dt><strong>size</strong></dt><dd>Specifies the initial size of the pane. The default is <strong>0</strong>.<p></p>
96
97</dd>
98<dt><strong>min</strong></dt><dd>Specifies the minimum size of the pane. The default is <strong>0</strong>.<p></p>
99
100</dd>
101<dt><strong>max</strong></dt><dd>Specifies the maximum size of the pane. The default is a
102 very large number.<p></p>
103<p> </p>
104
105
106</dd></dl>
107
108</dd>
109<dt> <h3>Components</h3></dt><dd>
110Components created by this megawidget and its base
111classes are described below.<p></p>
112<a name=component.hull></a>
113<dl><dt> <strong>hull
114</strong></dt><dd>
115This acts as the body for the entire megawidget. Other components
116 are created as children of the hull to further specialise this
117 class. By default, this component is a Tkinter.Frame.</p>
118
119
120</dd></dl>
121</dd>
122<dt> <h3>Dynamic components</h3></dt><dd>
123<p>
124 Frame, separator and handle components are created dynamically
125 by the <code>add()</code> and <code>insert()</code> methods. The components are of type
126 Tkinter.Frame and are created with component groups of
127 <strong>Frame</strong>, <strong>Separator</strong> and <strong>Handle</strong> respectively.</p>
128<p> </p>
129
130
131
132</dd>
133<a name=methods></a>
134<dt> <h3>Methods</h3></dt><dd>
135Only methods specific to this megawidget are described below.
136For a description of its inherited methods, see the
137manual for its base class
138<strong><a href="MegaWidget.html#methods">Pmw.MegaWidget</a></strong>.
139<p></p>
140<a name=method.add></a>
141<dl><dt> <strong>add</strong>(<em>name</em>, **<em>kw</em>)</dt><dd>
142Add a pane to the end of the paned widget as a component named
143 <em>name</em>. This is equivalent to calling <code>insert()</code> with <em>before</em>
144 set to the current number of panes. The method returns the <em>name</em>
145 component widget.</p>
146
147
148</dd></dl>
149<a name=method.configurepane></a>
150<dl><dt> <strong>configurepane</strong>(<em>name</em>, **<em>kw</em>)</dt><dd>
151Configure the pane specified by <em>name</em>, where <em>name</em> is either an
152 integer, specifying the index of the pane, or a string, specifying
153 the name of the pane. The keyword arguments specify the new
154 values for the options for the pane. These options are described
155 in the <strong>Pane options</strong> section.</p>
156
157
158</dd></dl>
159<a name=method.delete></a>
160<dl><dt> <strong>delete</strong>(<em>name</em>)</dt><dd>
161Delete the pane specified by <em>name</em>, where <em>name</em> is either an
162 integer, specifying the index of the pane, or a string, specifying
163 the name of the pane.</p>
164<p> If the pane deleted was not the only pane in the paned widget,
165 also delete the separator and handle components named
166 <strong>separator</strong>-<em>n</em> and <strong>handle</strong>-<em>n</em>, where <em>n</em> is the number of
167 panes remaining.</p>
168
169
170
171</dd></dl>
172<a name=method.insert></a>
173<dl><dt> <strong>insert</strong>(<em>name</em>, <em>before</em> = <strong>0</strong>, **<em>kw</em>)</dt><dd>
174Add a pane to the paned widget as a component named <em>name</em>. The
175 pane is added just before the pane specified by <em>before</em>, where
176 <em>before</em> may be either an integer, specifying the index of the
177 pane, or a string, specifying the name of the pane. The keyword
178 arguments specify the initial values for the options for the new
179 pane. These options are described in the <strong>Pane options</strong> section.
180 To add a pane to the end of the paned widget, use <code>add()</code>.</p>
181<p> The new pane is created as a Tkinter.Frame component named <em>name</em>.
182 If this is not the only pane, a separator and handle are also
183 created as components named <strong>separator</strong>-<em>n</em> and <strong>handle</strong>-<em>n</em>,
184 where <em>n</em> is one less than the number of panes. The method
185 returns the <em>name</em> component widget.</p>
186
187
188
189</dd></dl>
190<a name=method.move></a>
191<dl><dt> <strong>move</strong>(<em>name</em>, <em>newPos</em>, <em>newPosOffset</em> = <strong>0</strong>)</dt><dd>
192Move the pane specified by <em>name</em> to the new position specified by
193 <em>newPos</em>. The first two arguments may be either an integer,
194 specifying the index of the pane, or a string, specifying the name
195 of the pane. If <em>newPosOffset</em> is specified, it is added to the
196 <em>newPos</em> index. For example, to move a horizontal pane one pane
197 to the left, specify the name or index of the pane for both <em>name</em>
198 and <em>newPos</em> and specify <strong>-1</strong> for <em>newPosOffset</em>.</p>
199
200
201</dd></dl>
202<a name=method.pane></a>
203<dl><dt> <strong>pane</strong>(<em>name</em>)</dt><dd>
204Return the Tkinter.Frame pane widget for the pane specified by
205 <em>name</em>, where <em>name</em> is either an integer, specifying the index of
206 the pane, or a string, specifying the name of the pane.</p>
207
208
209</dd></dl>
210<a name=method.panes></a>
211<dl><dt> <strong>panes</strong>()</dt><dd>
212Return a list of the names of the panes, in display order.</p>
213
214
215</dd></dl>
216<a name=method.setnaturalsize></a>
217<dl><dt> <strong>setnaturalsize</strong>()</dt><dd>
218If oriented horizontally, set the width of the paned widget to the
219 sum of the requested widths of all panes and set the height to the
220 maximum requested height of all panes.</p>
221<p> If oriented vertically, set the height of the paned widget to the
222 sum of the requested heights of all panes and set the width to the
223 maximum requested width of all panes.</p>
224
225
226
227</dd></dl>
228<a name=method.updatelayout></a>
229<dl><dt> <strong>updatelayout</strong>()</dt><dd>
230Recalculate size and position of panes. This method must be
231 called after adding or deleting one or more panes. However it
232 does not need to be called when panes are first added to a newly
233 created paned widget, before it has been displayed.</p>
234
235
236</dd></dl>
237</dd>
238<dt> <h3>Example</h3></dt><dd>
239The image at the top of this manual is a snapshot
240of the window (or part of the window) produced
241by the following code.<p></p>
242<pre>
243class Demo:
244 def __init__(self, parent):
245
246 # Create a main PanedWidget with a few panes.
247 self.pw = Pmw.PanedWidget(parent,
248 orient='vertical',
249 hull_borderwidth = 1,
250 hull_relief = 'sunken',
251 hull_width=300,
252 hull_height=400)
253 for self.numPanes in range(4):
254 if self.numPanes == 1:
255 name = 'Fixed size'
256 pane = self.pw.add(name, min = .1, max = .1)
257 else:
258 name = 'Pane ' + str(self.numPanes)
259 pane = self.pw.add(name, min = .1, size = .25)
260 label = Tkinter.Label(pane, text = name)
261 label.pack(side = 'left', expand = 1)
262 button = Tkinter.Button(pane, text = 'Delete',
263 command = lambda s=self, n=name: s.deletePane(n))
264 button.pack(side = 'left', expand = 1)
265 # TODO: add buttons to invoke self.moveOneUp and self.moveOneUp.
266
267 self.pw.pack(expand = 1, fill='both')
268
269 buttonBox = Pmw.ButtonBox(parent)
270 buttonBox.pack(fill = 'x')
271 buttonBox.add('Add pane', command = self.addPane)
272 buttonBox.add('Move pane', command = self.move)
273 self.moveSrc = 0
274 self.moveNewPos = 1
275 self.moveBack = 0
276
277 def move(self):
278 numPanes = len(self.pw.panes())
279 if numPanes == 0:
280 print 'No panes to move!'
281 return
282
283 if self.moveSrc &gt;= numPanes:
284 self.moveSrc = numPanes - 1
285 if self.moveNewPos &gt;= numPanes:
286 self.moveNewPos = numPanes - 1
287 print 'Moving pane', self.moveSrc, 'to new position', self.moveNewPos
288 self.pw.move(self.moveSrc, self.moveNewPos)
289
290 self.moveSrc, self.moveNewPos = self.moveNewPos, self.moveSrc
291 if self.moveBack:
292 if self.moveNewPos == numPanes - 1:
293 self.moveNewPos = 0
294 if self.moveSrc == numPanes - 1:
295 self.moveSrc = 0
296 else:
297 self.moveSrc = self.moveSrc + 1
298 else:
299 self.moveNewPos = self.moveNewPos + 1
300 self.moveBack = not self.moveBack
301
302 def addPane(self):
303 self.numPanes = self.numPanes + 1
304 name = 'Pane ' + str(self.numPanes)
305 print 'Adding', name
306 pane = self.pw.add(name, min = .1, size = .25)
307 label = Tkinter.Label(pane, text = name)
308 label.pack(side = 'left', expand = 1)
309 button = Tkinter.Button(pane, text = 'Delete',
310 command = lambda s=self, n=name: s.deletePane(n))
311 button.pack(side = 'left', expand = 1)
312 self.pw.updatelayout()
313
314 def deletePane(self, name):
315 print 'Deleting', name
316 self.pw.delete(name)
317 self.pw.updatelayout()
318
319 def moveOneUp(self, name):
320 self.pw.move(name, name, -1)
321
322 def moveOneDown(self, name):
323 self.pw.move(name, name, 1)
324
325</pre>
326</dd>
327</dl>
328
329 <center><P ALIGN="CENTER">
330 <IMG SRC = blue_line.gif ALT = "" WIDTH=320 HEIGHT=5>
331 </p></center>
332
333
334 <font size=-1>
335 <center><P ALIGN="CENTER">
336 Pmw 1.2 -
337 5 Aug 2003
338 - <a href="index.html">Home</a>
339 <br>Manual page last reviewed: 14 April 2001
340 </p></center>
341 </font>
342
343 </body>
344 </html>
345