]> SALOME platform Git repositories - tools/eficas.git/blob - Pmw/Pmw_1_2/doc/ScrolledText.html
Salome HOME
Modif V6_4_°
[tools/eficas.git] / Pmw / Pmw_1_2 / doc / ScrolledText.html
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.ScrolledText 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.ScrolledText</h1>
13     
14 <center><IMG SRC=ScrolledText.gif ALT="" WIDTH=409 HEIGHT=310></center>
15 <dl>
16 <dt> <h3>Name</h3></dt><dd>
17 <p>Pmw.ScrolledText() - 
18     text widget with optional scrollbars
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 scrolled text consists of a standard text widget with optional
29     scrollbars which can be used to scroll the text.  The
30     scrollbars can be <em>dynamic</em>, which means that a scrollbar will
31     only be displayed if it is necessary.  That is, if the text widget
32     does not contain enough text (either horizontally or vertically),
33     the scrollbar will be automatically hidden.  If it is displayed,
34     the horizontal scrollbar is under the text widget.  Similarly, if
35     it is displayed, the vertical scrollbar is to the right of the
36     text widget.</p>
37
38 <p>    Row and column headers may also be displayed, which scroll in sync
39     with the text widget and may be useful when displaying tabular
40     data.  To assist in ensuring that columns line up when using a
41     column header, a fixed width font should be used.</p>
42
43 <p></p>
44
45
46 </dd>
47 <dt> <h3>Options</h3></dt><dd>
48 Options for this megawidget and its base
49 classes are described below.<p></p>
50 <a name=option.borderframe></a>
51 <dl><dt> <strong>borderframe
52 </strong></dt><dd>
53 Initialisation option. If true, the <strong>borderframe</strong> component will be created. The default is <strong>0</strong>.</p>
54
55
56 </dd></dl>
57 <a name=option.columnheader></a>
58 <dl><dt> <strong>columnheader
59 </strong></dt><dd>
60 Initialisation option. If true, the <strong>columnheader</strong> component will be created. The default is <strong>0</strong>.</p>
61
62
63 </dd></dl>
64 <a name=option.hscrollmode></a>
65 <dl><dt> <strong>hscrollmode
66 </strong></dt><dd>
67 The horizontal scroll mode.  If <strong>'none'</strong>, the horizontal scrollbar
68     will never be displayed.  If <strong>'static'</strong>, the scrollbar will always
69     be displayed.  If <strong>'dynamic'</strong>, the scrollbar will be displayed
70     only if necessary. The default is <strong>'dynamic'</strong>.</p>
71
72
73 </dd></dl>
74 <a name=option.labelmargin></a>
75 <dl><dt> <strong>labelmargin
76 </strong></dt><dd>
77 Initialisation option. If the <strong>labelpos</strong> option is not <strong>None</strong>, this specifies the
78         distance between the <strong>label</strong> component and the rest of the
79         megawidget. The default is <strong>0</strong>.</p>
80
81
82 </dd></dl>
83 <a name=option.labelpos></a>
84 <dl><dt> <strong>labelpos
85 </strong></dt><dd>
86 Initialisation option. Specifies where to place the <strong>label</strong> component.  If not
87         <strong>None</strong>, it should be a concatenation of one or two of the
88         letters <strong>'n'</strong>, <strong>'s'</strong>, <strong>'e'</strong> and <strong>'w'</strong>.  The first letter
89         specifies on which side of the megawidget to place the label. 
90         If a second letter is specified, it indicates where on that
91         side to place the label.  For example, if <strong>labelpos</strong> is <strong>'w'</strong>,
92         the label is placed in the center of the left hand side; if
93         it is <strong>'wn'</strong>, the label is placed at the top of the left
94         hand side; if it is <strong>'ws'</strong>, the label is placed at the
95         bottom of the left hand side.</p>
96 <p>        If <strong>None</strong>, a label component is not created. The default is <strong>None</strong>.</p>
97
98
99
100 </dd></dl>
101 <a name=option.rowcolumnheader></a>
102 <dl><dt> <strong>rowcolumnheader
103 </strong></dt><dd>
104 Initialisation option. If true, the <strong>rowcolumnheader</strong> component will be created. The default is <strong>0</strong>.</p>
105
106
107 </dd></dl>
108 <a name=option.rowheader></a>
109 <dl><dt> <strong>rowheader
110 </strong></dt><dd>
111 Initialisation option. If true, the <strong>rowheader</strong> component will be created. The default is <strong>0</strong>.</p>
112
113
114 </dd></dl>
115 <a name=option.scrollmargin></a>
116 <dl><dt> <strong>scrollmargin
117 </strong></dt><dd>
118 Initialisation option. The distance between the scrollbars and the text widget. The default is <strong>2</strong>.</p>
119
120
121 </dd></dl>
122 <a name=option.usehullsize></a>
123 <dl><dt> <strong>usehullsize
124 </strong></dt><dd>
125 Initialisation option. If true, the size of the megawidget is determined solely by the
126     width and height options of the <strong>hull</strong> component.</p>
127 <p>    Otherwise, the size of the megawidget is determined by the width
128     and height of the <strong>text</strong> component, along with the size and/or
129     existence of the other components, such as the label, the
130     scrollbars and the scrollmargin option.  All these affect the
131     overall size of the megawidget. The default is <strong>0</strong>.</p>
132
133
134
135 </dd></dl>
136 <a name=option.vscrollmode></a>
137 <dl><dt> <strong>vscrollmode
138 </strong></dt><dd>
139 The vertical scroll mode.  If <strong>'none'</strong>, the vertical scrollbar
140     will never be displayed.  If <strong>'static'</strong>, the scrollbar will always
141     be displayed.  If <strong>'dynamic'</strong>, the scrollbar will be displayed
142     only if necessary. The default is <strong>'dynamic'</strong>.</p>
143
144
145 </dd></dl>
146 </dd>
147 <dt> <h3>Components</h3></dt><dd>
148 Components created by this megawidget and its base
149 classes are described below.<p></p>
150 <a name=component.borderframe></a>
151 <dl><dt> <strong>borderframe
152 </strong></dt><dd>
153 A frame widget which snuggly fits around the text widget, to give
154     the appearance of a text border.  It is created with a border so
155     that the text widget, which is created without a border, looks
156     like it has a border. By default, this component is a Tkinter.Frame.</p>
157
158
159 </dd></dl>
160 <a name=component.columnheader></a>
161 <dl><dt> <strong>columnheader
162 </strong></dt><dd>
163 A text widget with a default height of 1 displayed above the main
164     text widget and which scrolls horizontally in sync with the
165     horizontal scrolling of the main text widget. By default, this component is a Tkinter.Text. Its component group is <strong>Header</strong>.</p>
166
167
168 </dd></dl>
169 <a name=component.horizscrollbar></a>
170 <dl><dt> <strong>horizscrollbar
171 </strong></dt><dd>
172 The horizontal scrollbar. By default, this component is a Tkinter.Scrollbar. Its component group is <strong>Scrollbar</strong>.</p>
173
174
175 </dd></dl>
176 <a name=component.hull></a>
177 <dl><dt> <strong>hull
178 </strong></dt><dd>
179 This acts as the body for the entire megawidget.  Other components
180     are created as children of the hull to further specialise this
181     class. By default, this component is a Tkinter.Frame.</p>
182
183
184 </dd></dl>
185 <a name=component.label></a>
186 <dl><dt> <strong>label
187 </strong></dt><dd>
188 If the <strong>labelpos</strong> option is not <strong>None</strong>, this component is
189         created as a text label for the megawidget.  See the
190         <strong>labelpos</strong> option for details.  Note that to set, for example,
191         the <strong>text</strong> option of the label, you need to use the <strong>label_text</strong>
192         component option. By default, this component is a Tkinter.Label.</p>
193
194
195 </dd></dl>
196 <a name=component.rowcolumnheader></a>
197 <dl><dt> <strong>rowcolumnheader
198 </strong></dt><dd>
199 A text widget displayed to the top left of the main text widget,
200     above the row header and to the left of the column header if they
201     exist.  The widget is not scrolled  automatically. By default, this component is a Tkinter.Text. Its component group is <strong>Header</strong>.</p>
202
203
204 </dd></dl>
205 <a name=component.rowheader></a>
206 <dl><dt> <strong>rowheader
207 </strong></dt><dd>
208 A text widget displayed to the left of the main text widget and
209     which scrolls vertically in sync with the vertical scrolling of
210     the main text widget. By default, this component is a Tkinter.Text. Its component group is <strong>Header</strong>.</p>
211
212
213 </dd></dl>
214 <a name=component.text></a>
215 <dl><dt> <strong>text
216 </strong></dt><dd>
217 The text widget which is scrolled by the scrollbars.  If the
218     <strong>borderframe</strong> option is true, this is created with a borderwidth
219     of <strong>0</strong> to overcome a known problem with text widgets:  if a widget
220     inside a text widget extends across one of the edges of the text
221     widget, then the widget obscures the border of the text widget. 
222     Therefore, if the text widget has no border, then this overlapping
223     does not occur. By default, this component is a Tkinter.Text.</p>
224
225
226 </dd></dl>
227 <a name=component.vertscrollbar></a>
228 <dl><dt> <strong>vertscrollbar
229 </strong></dt><dd>
230 The vertical scrollbar. By default, this component is a Tkinter.Scrollbar. Its component group is <strong>Scrollbar</strong>.</p>
231
232
233 </dd></dl>
234 </dd>
235 <a name=methods></a>
236 <dt> <h3>Methods</h3></dt><dd>
237 Only methods specific to this megawidget are described below.
238 For a description of its inherited methods, see the
239 manual for its base class
240 <strong><a href="MegaWidget.html#methods">Pmw.MegaWidget</a></strong>.
241 In addition, methods from the
242 <strong>Tkinter.Text</strong> class
243 are forwarded by this megawidget to the
244 <strong>text</strong> component.
245 <p></p>
246 <a name=method.appendtext></a>
247 <dl><dt> <strong>appendtext</strong>(<em>text</em>)</dt><dd>
248 Add <em>text</em> to the end of the <strong>text</strong> component.  Scroll to the
249     bottom of the text, but only if it was already visible before the
250     new text was added.</p>
251
252
253 </dd></dl>
254 <a name=method.bbox></a>
255 <dl><dt> <strong>bbox</strong>(<em>index</em>)</dt><dd>
256 This method is explicitly forwarded to the <strong>text</strong> component's
257     <code>bbox()</code> method.  Without this explicit forwarding, the <code>bbox()</code>
258     method (aliased to <code>grid_bbox()</code>) of the <strong>hull</strong> would be invoked,
259     which is probably not what the programmer intended.</p>
260
261
262 </dd></dl>
263 <a name=method.clear></a>
264 <dl><dt> <strong>clear</strong>()</dt><dd>
265 Delete all text from the <strong>text</strong> component.</p>
266
267
268 </dd></dl>
269 <a name=method.exportfile></a>
270 <dl><dt> <strong>exportfile</strong>(<em>fileName</em>)</dt><dd>
271 Write the contents of the <strong>text</strong> component to the file <em>fileName</em>.</p>
272
273
274 </dd></dl>
275 <a name=method.get></a>
276 <dl><dt> <strong>get</strong>(<em>first</em> = <strong>None</strong>, <em>last</em> = <strong>None</strong>)</dt><dd>
277 This is the same as the <code>get()</code> method of the <strong>text</strong> component,
278     except that if <em>first</em> is <strong>None</strong> the entire
279     contents of the text widget are returned.</p>
280
281
282 </dd></dl>
283 <a name=method.getvalue></a>
284 <dl><dt> <strong>getvalue</strong>()</dt><dd>
285 Return the entire contents of the text widget.</p>
286
287
288 </dd></dl>
289 <a name=method.importfile></a>
290 <dl><dt> <strong>importfile</strong>(<em>fileName</em>, <em>where</em> = <strong>'end'</strong>)</dt><dd>
291 Read the contents of the file <em>fileName</em> and insert into the
292     <strong>text</strong> component at the position given by <em>where</em>.</p>
293
294
295 </dd></dl>
296 <a name=method.settext></a>
297 <dl><dt> <strong>settext</strong>(<em>text</em>)</dt><dd>
298 Same as <code>setvalue()</code> method.</p>
299
300
301 </dd></dl>
302 <a name=method.setvalue></a>
303 <dl><dt> <strong>setvalue</strong>(<em>text</em>)</dt><dd>
304 Replace the entire contents of the <strong>text</strong> component with <em>text</em>.</p>
305
306
307 </dd></dl>
308 </dd>
309 <dt> <h3>Example</h3></dt><dd>
310 The image at the top of this manual is a snapshot
311 of the window (or part of the window) produced
312 by the following code.<p></p>
313 <pre>
314 class Demo:
315     def __init__(self, parent):
316
317         # Create the ScrolledText with headers.
318         fixedFont = Pmw.logicalfont('Fixed')
319         self.st = Pmw.ScrolledText(parent,
320                 # borderframe = 1,
321                 labelpos = 'n',
322                 label_text='ScrolledText with headers',
323                 columnheader = 1,
324                 rowheader = 1,
325                 rowcolumnheader = 1,
326                 usehullsize = 1,
327                 hull_width = 400,
328                 hull_height = 300,
329                 text_wrap='none',
330                 text_font = fixedFont,
331                 Header_font = fixedFont,
332                 Header_foreground = 'blue',
333                 rowheader_width = 3,
334                 rowcolumnheader_width = 3,
335                 text_padx = 4,
336                 text_pady = 4,
337                 Header_padx = 4,
338                 rowheader_pady = 4,
339         )
340
341         self.st.pack(padx = 5, pady = 5, fill = 'both', expand = 1)
342
343         funcs = 'atan cos cosh exp log log10 sin sinh sqrt tan tanh'
344         funcs = string.split(funcs)
345
346         # Create the header for the row headers
347         self.st.component('rowcolumnheader').insert('end', 'x')
348
349         # Create the column headers
350         headerLine = ''
351         for column in range(len(funcs)):
352             headerLine = headerLine + ('%-7s   ' % (funcs[column],))
353         headerLine = headerLine[:-3]
354         self.st.component('columnheader').insert('0.0', headerLine)
355
356         self.st.tag_configure('yellow', background = 'yellow')
357
358         # Create the data rows and the row headers
359         numRows = 50
360         tagList = []
361         for row in range(1, numRows):
362             dataLine = ''
363             x = row / 5.0
364             for column in range(len(funcs)):
365                 value = eval('math.' + funcs[column] + '(' + str(x) + ')')
366                 data = str(value)[:7]
367                 if value &lt; 0:
368                     tag1 = '%d.%d' % (row, len(dataLine))
369                     tag2 = '%d.%d' % (row, len(dataLine) + len(data))
370                     tagList.append(tag1)
371                     tagList.append(tag2)
372                 data = '%-7s' % (data,)
373                 dataLine = dataLine + data + '   '
374             dataLine = dataLine[:-3]
375             header = '%.1f' % (x,)
376             if row &lt; numRows - 1:
377                 dataLine = dataLine + '\n'
378                 header = header + '\n'
379             self.st.insert('end', dataLine)
380             self.st.component('rowheader').insert('end', header)
381         apply(self.st.tag_add, ('yellow',) + tuple(tagList))
382
383         # Prevent users' modifying text and headers
384         self.st.configure(
385             text_state = 'disabled',
386             Header_state = 'disabled',
387         )
388
389 </pre>
390 </dd>
391 </dl>
392
393     <center><P ALIGN="CENTER">
394     <IMG SRC = blue_line.gif ALT = "" WIDTH=320 HEIGHT=5>
395     </p></center>
396     
397
398     <font size=-1>
399     <center><P ALIGN="CENTER">
400     Pmw 1.2 -
401      5 Aug 2003
402      - <a href="index.html">Home</a>
403     <br>Manual page last reviewed: 30 August 1998
404     </p></center>
405     </font>
406
407     </body>
408     </html>
409