Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / devtools / amd64 / lib / python2.4 / site-packages / Pmw / Pmw_1_2 / doc / MessageBar.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.MessageBar 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.MessageBar</h1>
13
14<center><IMG SRC=MessageBar.gif ALT="" WIDTH=398 HEIGHT=44></center>
15<dl>
16<dt> <h3>Name</h3></dt><dd>
17<p>Pmw.MessageBar() -
18 information line for displaying short messages
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 message bar contains a single-line message display area. Messages
29 of several different types may displayed. Messages are cleared
30 after a period defined for each message type. Each message type
31 has a priority so that if the application attempts to display more
32 than one message at a time, the message with the highest priority
33 will be displayed. Messages may be accompanied by a number of
34 audible bells.</p>
35
36<p> This megawidget can be used for both interactive help messages
37 (when the mouse enters certain widgets) and also for other general
38 messages.</p>
39
40<p> To perform the help function it can cooperate with the <a href="Balloon.html">Pmw.Balloon</a>
41 megawidget so that the programmer (or user) can choose either
42 balloon help, message bar help, both or neither.</p>
43
44<p> This megawidget supports a configurable number of message types.
45 The default types include <strong>'state'</strong>, <strong>'help'</strong>, <strong>'usererror'</strong> and
46 <strong>'systemerror'</strong>. The difference between these are the length of
47 time they are displayed, the number of bells that are rung and the
48 priority of the message. For example, the <strong>'help'</strong> message type
49 is lower in priority than the <strong>'usererror'</strong>, so that error
50 messages will always be displayed in preference to help messages
51 regardless of the order the messages are created. The <strong>'state'</strong>
52 message type is lowest in priority but has no timeout, so it
53 should contain messages describing the current state of the
54 application, such as <em>Waiting for database connection</em> or 'Waiting
55 for file to be unlocked'. Generally this should be set to the
56 empty string when the application is running normally. By default
57 the help messages (with message type <strong>'help'</strong>) time out after 5
58 seconds, so that if the cursor happens to be left over a widget,
59 the application state will be redisplayed after a short time.</p>
60
61<p></p>
62
63
64</dd>
65<dt> <h3>Options</h3></dt><dd>
66Options for this megawidget and its base
67classes are described below.<p></p>
68<a name=option.labelmargin></a>
69<dl><dt> <strong>labelmargin
70</strong></dt><dd>
71Initialisation option. If the <strong>labelpos</strong> option is not <strong>None</strong>, this specifies the
72 distance between the <strong>label</strong> component and the rest of the
73 megawidget. The default is <strong>0</strong>.</p>
74
75
76</dd></dl>
77<a name=option.labelpos></a>
78<dl><dt> <strong>labelpos
79</strong></dt><dd>
80Initialisation option. Specifies where to place the <strong>label</strong> component. If not
81 <strong>None</strong>, it should be a concatenation of one or two of the
82 letters <strong>'n'</strong>, <strong>'s'</strong>, <strong>'e'</strong> and <strong>'w'</strong>. The first letter
83 specifies on which side of the megawidget to place the label.
84 If a second letter is specified, it indicates where on that
85 side to place the label. For example, if <strong>labelpos</strong> is <strong>'w'</strong>,
86 the label is placed in the center of the left hand side; if
87 it is <strong>'wn'</strong>, the label is placed at the top of the left
88 hand side; if it is <strong>'ws'</strong>, the label is placed at the
89 bottom of the left hand side.</p>
90<p> If <strong>None</strong>, a label component is not created. The default is <strong>None</strong>.</p>
91
92
93
94</dd></dl>
95<a name=option.messagetypes></a>
96<dl><dt> <strong>messagetypes
97</strong></dt><dd>
98Initialisation option. This defines what message types are supported by the message bar
99 and the characteristics of those message types. It is a
100 dictionary where the key is a string specifying a message type and
101 the value is a tuple of four integers, (<em>priority</em>, <em>showtime</em>,
102 <em>bells</em>, <em>logmessage</em>), where <em>priority</em> is the rank of the
103 message type, <em>showtime</em> is the number of seconds to display
104 messages of this message type, <em>bells</em> is the number of audible
105 bells to ring and <em>logmessage</em> is a boolean
106 specifying whether this message should be logged for retrieval
107 later. Messages with a higher priority are displayed in
108 preference to those with lower priority. If a high priority
109 message times out (because it has been displayed for <em>showtime</em>
110 seconds), then a lower priority message may be displayed. A
111 <em>showtime</em> of <strong>0</strong> means that the message will never time out and
112 is useful for displaying messages describing the current state of
113 the application as opposed to messages describing events. Logging
114 is not currently implemented. The default is</p>
115<dl><dd><pre> {
116 'systemerror' : (5, 10, 2, 1),
117 'usererror' : (4, 5, 1, 0),
118 'busy' : (3, 0, 0, 0),
119 'systemevent' : (2, 5, 0, 0),
120 'userevent' : (2, 5, 0, 0),
121 'help' : (1, 5, 0, 0),
122 'state' : (0, 0, 0, 0),
123 }</pre></dd></dl>
124
125
126
127</dd></dl>
128<a name=option.silent></a>
129<dl><dt> <strong>silent
130</strong></dt><dd>
131If true, no audible bells will sound, regardless of the value for
132 <em>bells</em> defined in the <strong>messagetypes</strong> option. The default is <strong>0</strong>.</p>
133
134
135</dd></dl>
136<a name=option.sticky></a>
137<dl><dt> <strong>sticky
138</strong></dt><dd>
139Initialisation option. The default is <strong>'ew'</strong>.</p>
140
141
142</dd></dl>
143</dd>
144<dt> <h3>Components</h3></dt><dd>
145Components created by this megawidget and its base
146classes are described below.<p></p>
147<a name=component.entry></a>
148<dl><dt> <strong>entry
149</strong></dt><dd>
150The widget where the messages are displayed. Long messages may be
151 scrolled horizontally by dragging with the middle mouse button. By default, this component is a Tkinter.Entry.</p>
152
153
154</dd></dl>
155<a name=component.hull></a>
156<dl><dt> <strong>hull
157</strong></dt><dd>
158This acts as the body for the entire megawidget. Other components
159 are created as children of the hull to further specialise this
160 class. By default, this component is a Tkinter.Frame.</p>
161
162
163</dd></dl>
164<a name=component.label></a>
165<dl><dt> <strong>label
166</strong></dt><dd>
167If the <strong>labelpos</strong> option is not <strong>None</strong>, this component is
168 created as a text label for the megawidget. See the
169 <strong>labelpos</strong> option for details. Note that to set, for example,
170 the <strong>text</strong> option of the label, you need to use the <strong>label_text</strong>
171 component option. By default, this component is a Tkinter.Label.</p>
172
173
174</dd></dl>
175</dd>
176<a name=methods></a>
177<dt> <h3>Methods</h3></dt><dd>
178Only methods specific to this megawidget are described below.
179For a description of its inherited methods, see the
180manual for its base class
181<strong><a href="MegaWidget.html#methods">Pmw.MegaWidget</a></strong>.
182In addition, methods from the
183<strong>Tkinter.Entry</strong> class
184are forwarded by this megawidget to the
185<strong>entry</strong> component.
186<p></p>
187<a name=method.helpmessage></a>
188<dl><dt> <strong>helpmessage</strong>(<em>text</em>)</dt><dd>
189A convenience method to display <em>text</em> in the message bar
190 according to the characteristics defined by the <strong>help</strong> message type.
191 Equivalent to <code>message('help', text)</code>.</p>
192
193
194</dd></dl>
195<a name=method.message></a>
196<dl><dt> <strong>message</strong>(<em>type</em>, <em>text</em>)</dt><dd>
197Display <em>text</em> in the message bar according to the characteristics
198 defined by the <em>type</em> message type, as discussed under
199 <strong>messagetypes</strong>.</p>
200
201
202</dd></dl>
203<a name=method.resetmessages></a>
204<dl><dt> <strong>resetmessages</strong>(<em>type</em>)</dt><dd>
205Clear the <em>type</em> message and all message types with a lower
206 priority, except permanent messages, such as <strong>state</strong>. This is
207 useful to clear the <strong>busy</strong> message and any outstanding event and
208 help messages.</p>
209
210
211</dd></dl>
212</dd>
213<dt> <h3>Example</h3></dt><dd>
214The image at the top of this manual is a snapshot
215of the window (or part of the window) produced
216by the following code.<p></p>
217<pre>
218class Demo:
219 def __init__(self, parent):
220 # Create and pack the MessageBar.
221 self._messagebar = Pmw.MessageBar(parent,
222 entry_width = 40,
223 entry_relief='groove',
224 labelpos = 'w',
225 label_text = 'Status:')
226 self._messagebar.pack(side = 'bottom', fill = 'x',
227 expand = 1, padx = 10, pady = 10)
228
229 # Create and pack the ScrolledListBox to change the MessageBar.
230 self.box = Pmw.ScrolledListBox(parent,
231 listbox_selectmode='single',
232 items=('state', 'help', 'userevent', 'systemevent',
233 'usererror', 'systemerror', 'busy',),
234 label_text='Message type',
235 labelpos='n',
236 selectioncommand=self.selectionCommand)
237 self.box.pack(fill = 'both', expand = 'yes', padx = 10, pady = 10)
238
239 self._index = 0
240 self._stateCounter = 0
241
242 def selectionCommand(self):
243 sels = self.box.getcurselection()
244 if len(sels) &gt; 0:
245 self._index = self._index + 1
246 messagetype = sels[0]
247 if messagetype == 'state':
248 self._stateCounter = (self._stateCounter + 1) % 3
249 text = stateMessages[self._stateCounter]
250 if text != '':
251 text = text + ' (' + messagetype + ')'
252 self._messagebar.message('state', text)
253 else:
254 text = messages[messagetype]
255 text = text + ' (' + messagetype + ')'
256 self._messagebar.message(messagetype, text)
257 if messagetype == 'busy':
258 Pmw.showbusycursor()
259 self.box.after(2000)
260 Pmw.hidebusycursor()
261 self._messagebar.resetmessages('busy')
262 text = 'All files successfully removed'
263 text = text + ' (userevent)'
264 self._messagebar.message('userevent', text)
265
266
267messages = {
268 'help': 'Save current file',
269 'userevent': 'Saving file "foo"',
270 'busy': 'Busy deleting all files from file system ...',
271 'systemevent': 'File "foo" saved',
272 'usererror': 'Invalid file name "foo/bar"',
273 'systemerror': 'Failed to save file: file system full',
274}
275
276stateMessages = {
277 0: '',
278 1: 'Database is down',
279 2: 'Waiting for reply from database',
280}
281
282</pre>
283</dd>
284</dl>
285
286 <center><P ALIGN="CENTER">
287 <IMG SRC = blue_line.gif ALT = "" WIDTH=320 HEIGHT=5>
288 </p></center>
289
290
291 <font size=-1>
292 <center><P ALIGN="CENTER">
293 Pmw 1.2 -
294 5 Aug 2003
295 - <a href="index.html">Home</a>
296
297 </p></center>
298 </font>
299
300 </body>
301 </html>
302