Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / devtools / v9 / lib / python2.4 / site-packages / Pmw / Pmw_1_2 / doc / MessageDialog.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.MessageDialog 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.MessageDialog</h1>
13
14<center><IMG SRC=MessageDialog.gif ALT="" WIDTH=309 HEIGHT=220></center>
15<dl>
16<dt> <h3>Name</h3></dt><dd>
17<p>Pmw.MessageDialog() -
18 a dialog displaying a text message and an icon
19</p>
20
21
22</dd>
23<dt> <h3>Inherits</h3></dt><dd>
24<a href="Dialog.html">Pmw.Dialog</a><br>
25</dd>
26<dt> <h3>Description</h3></dt><dd>
27<p>
28 A message dialog is a dialog window which displays a simple
29 message to the user along with one or more buttons to press.</p>
30
31<p></p>
32
33
34</dd>
35<dt> <h3>Options</h3></dt><dd>
36Options for this megawidget and its base
37classes are described below.<p></p>
38<a name=option.activatecommand></a>
39<dl><dt> <strong>activatecommand
40</strong></dt><dd>
41If this is callable, it will be called whenever the megawidget is
42 activated by a call to <code>activate()</code>. The default is <strong>None</strong>.</p>
43
44
45</dd></dl>
46<a name=option.borderx></a>
47<dl><dt> <strong>borderx
48</strong></dt><dd>
49Initialisation option. The padding to the left and right of the text message and icon. The default is <strong>20</strong>.</p>
50
51
52</dd></dl>
53<a name=option.bordery></a>
54<dl><dt> <strong>bordery
55</strong></dt><dd>
56Initialisation option. The padding above and below the text message and icon. The default is <strong>20</strong>.</p>
57
58
59</dd></dl>
60<a name=option.buttonboxpos></a>
61<dl><dt> <strong>buttonboxpos
62</strong></dt><dd>
63Initialisation option. Specifies on which side of the dialog window to place the button
64 box. Must be one of <strong>'n'</strong>, <strong>'s'</strong>, <strong>'e'</strong> or <strong>'w'</strong>. The default is <strong>'s'</strong>.</p>
65
66
67</dd></dl>
68<a name=option.buttons></a>
69<dl><dt> <strong>buttons
70</strong></dt><dd>
71This must be a tuple or a list and specifies the names on the
72 buttons in the button box. The default is <strong>('OK',)</strong>.</p>
73
74
75</dd></dl>
76<a name=option.command></a>
77<dl><dt> <strong>command
78</strong></dt><dd>
79Specifies a function to call whenever a button in the button box
80 is invoked or the window is deleted by the window manager. The
81 function is called with a single argument, which is the name of
82 the button which was invoked, or <strong>None</strong> if the window was deleted
83 by the window manager.</p>
84<p> If the value of <strong>command</strong> is not callable, the default behaviour
85 is to deactivate the window if it is active, or withdraw the
86 window if it is not active. If it is deactivated, <code>deactivate()</code>
87 is called with the button name or <strong>None</strong> as described above. The default is <strong>None</strong>.</p>
88
89
90
91</dd></dl>
92<a name=option.deactivatecommand></a>
93<dl><dt> <strong>deactivatecommand
94</strong></dt><dd>
95If this is callable, it will be called whenever the megawidget is
96 deactivated by a call to <code>deactivate()</code>. The default is <strong>None</strong>.</p>
97
98
99</dd></dl>
100<a name=option.defaultbutton></a>
101<dl><dt> <strong>defaultbutton
102</strong></dt><dd>
103Specifies the default button in the button box. If the <strong>&lt;Return&gt;</strong>
104 key is hit when the dialog has focus, the default button will be
105 invoked. If <strong>defaultbutton</strong> is <strong>None</strong>, there will be no default
106 button and hitting the <strong>&lt;Return&gt;</strong> key will have no effect. The default is <strong>None</strong>.</p>
107
108
109</dd></dl>
110<a name=option.iconmargin></a>
111<dl><dt> <strong>iconmargin
112</strong></dt><dd>
113Initialisation option. The padding between the text message and icon. The default is <strong>20</strong>.</p>
114
115
116</dd></dl>
117<a name=option.iconpos></a>
118<dl><dt> <strong>iconpos
119</strong></dt><dd>
120Initialisation option. Specifies on which side of the text message to place the icon.
121 Must be one of <strong>'n'</strong>, <strong>'s'</strong>, <strong>'e'</strong> or <strong>'w'</strong>. The default is <strong>None</strong>.</p>
122
123
124</dd></dl>
125<a name=option.master></a>
126<dl><dt> <strong>master
127</strong></dt><dd>
128This is used by the <code>activate()</code> method to control whether the
129 window is made <em>transient</em> during modal dialogs. See the
130 <code>activate()</code> method. The default is <strong>'parent'</strong>.</p>
131
132
133</dd></dl>
134<a name=option.separatorwidth></a>
135<dl><dt> <strong>separatorwidth
136</strong></dt><dd>
137Initialisation option. If this is greater than <strong>0</strong>, a separator line with the specified
138 width will be created between the button box and the child site,
139 as a component named <strong>separator</strong>. Since the default border of the
140 button box and child site is <strong>raised</strong>, this option does not
141 usually need to be set for there to be a visual separation between
142 the button box and child site. The default is <strong>0</strong>.</p>
143
144
145</dd></dl>
146<a name=option.title></a>
147<dl><dt> <strong>title
148</strong></dt><dd>
149This is the title that the window manager displays in the title
150 bar of the window. The default is <strong>None</strong>.</p>
151
152
153</dd></dl>
154</dd>
155<dt> <h3>Components</h3></dt><dd>
156Components created by this megawidget and its base
157classes are described below.<p></p>
158<a name=component.buttonbox></a>
159<dl><dt> <strong>buttonbox
160</strong></dt><dd>
161This is the button box containing the buttons for the dialog. By
162 default it is created with the options
163 <code>(hull_borderwidth = 1, hull_relief = 'raised')</code>. By default, this component is a <a href="ButtonBox.html">Pmw.ButtonBox</a>.</p>
164
165
166</dd></dl>
167<a name=component.dialogchildsite></a>
168<dl><dt> <strong>dialogchildsite
169</strong></dt><dd>
170This is the child site for the dialog, which may be used to
171 specialise the megawidget by creating other widgets within it. By
172 default it is created with the options
173 <code>(borderwidth = 1, relief = 'raised')</code>. By default, this component is a Tkinter.Frame.</p>
174
175
176</dd></dl>
177<a name=component.hull></a>
178<dl><dt> <strong>hull
179</strong></dt><dd>
180This acts as the body for the entire megawidget. Other components
181 are created as children of the hull to further specialise this
182 class. By default, this component is a Tkinter.Toplevel.</p>
183
184
185</dd></dl>
186<a name=component.icon></a>
187<dl><dt> <strong>icon
188</strong></dt><dd>
189If the <strong>iconpos</strong> option is not <strong>None</strong>, this component is created
190 to contain the icon label for the dialog. To display a bitmap as
191 an icon, set the <strong>icon_bitmap</strong> component option to any of the
192 forms acceptable to Tk, such as <strong>'warning'</strong> or <strong>'error'</strong>. By default, this component is a Tkinter.Label.</p>
193
194
195</dd></dl>
196<a name=component.message></a>
197<dl><dt> <strong>message
198</strong></dt><dd>
199The label to contain the text message for the dialog. To set
200 the text, use the <strong>message_text</strong> component option. By default, this component is a Tkinter.Label.</p>
201
202
203</dd></dl>
204<a name=component.separator></a>
205<dl><dt> <strong>separator
206</strong></dt><dd>
207If the <strong>separatorwidth</strong> initialisation option is non-zero, the
208 <strong>separator</strong> component is the line dividing the area between the
209 button box and the child site. By default, this component is a Tkinter.Frame.</p>
210
211
212</dd></dl>
213</dd>
214<a name=methods></a>
215<dt> <h3>Methods</h3></dt><dd>
216This megawidget has no methods of its own.
217For a description of its inherited methods, see the
218manual for its base class
219<strong><a href="Dialog.html#methods">Pmw.Dialog</a></strong>.
220<p></p>
221</dd>
222<dt> <h3>Example</h3></dt><dd>
223The image at the top of this manual is a snapshot
224of the window (or part of the window) produced
225by the following code.<p></p>
226<pre>
227class Demo:
228 def __init__(self, parent):
229 self.parent = parent
230
231 # Create dialog 1.
232 self.dialog1 = Pmw.MessageDialog(parent,
233 title = 'Simple message dialog',
234 defaultbutton = 0,
235 message_text = 'A simple message dialog\nwith no callback.')
236 self.dialog1.iconname('Simple message dialog')
237 self.dialog1.withdraw()
238
239 # Create dialog 2.
240 self.dialog2 = Pmw.MessageDialog(parent,
241 title = 'Bell ringing dialog',
242 message_text = 'This message dialog\nwill ring the bell ' +
243 'when\nyou click on the buttons.',
244 iconpos = 'w',
245 icon_bitmap = 'error',
246 command = self.execute2,
247 buttons = ('One', 'Two', 'Three', 'Close'))
248 self.dialog2.iconname('Bell ringing dialog')
249 self.dialog2.withdraw()
250
251 # Create dialog 3.
252 self.dialog3 = Pmw.MessageDialog(parent,
253 title = 'Vertical button dialog',
254 message_text = 'This message dialog\nhas the buttons on the\n' +
255 'right hand side.',
256 buttonboxpos = 'e',
257 iconpos = 'n',
258 icon_bitmap = 'warning',
259 buttons = ('Goodbye', 'Au revoir', 'Sayonara', 'Close'),
260 defaultbutton = 'Close')
261 self.dialog3.iconname('Vertical button dialog')
262 self.dialog3.withdraw()
263
264 # Create some buttons to launch the dialogs.
265 w = Tkinter.Button(parent, text = 'Simple dialog',
266 command = lambda self = self:
267 self.dialog1.activate(geometry = 'first+100+100'))
268 w.pack(padx = 8, pady = 8)
269
270 w = Tkinter.Button(parent, text = 'Bell ringing dialog',
271 command = self.dialog2.activate)
272 w.pack(padx = 8, pady = 8)
273
274 w = Tkinter.Button(parent, text = 'Vertical buttons',
275 command = self.dialog3.activate)
276 w.pack(padx = 8, pady = 8)
277
278 w = Tkinter.Button(parent, text = 'On the fly dialog',
279 command = self._createOnTheFly)
280 w.pack(padx = 8, pady = 8)
281
282 def execute2(self, result):
283 print 'You clicked on', result
284 if result is None:
285 self.dialog2.deactivate(result)
286 elif result == 'Close':
287 self.dialog2.deactivate(result)
288 else:
289 for count in range({'One': 1, 'Two': 2, 'Three': 3}[result]):
290 if count != 0:
291 self.dialog2.after(200)
292 self.dialog2.bell()
293
294 def _createOnTheFly(self):
295 dialog = Pmw.MessageDialog(self.parent,
296 title = 'On the fly dialog',
297 defaultbutton = 0,
298 buttons = ('OK', 'Apply', 'Cancel', 'Help'),
299 message_text = 'This dialog was created when you clicked ' +
300 'on the button.')
301 dialog.iconname('Simple message dialog')
302 result = dialog.activate()
303
304 print 'You selected', result
305
306</pre>
307</dd>
308</dl>
309
310 <center><P ALIGN="CENTER">
311 <IMG SRC = blue_line.gif ALT = "" WIDTH=320 HEIGHT=5>
312 </p></center>
313
314
315 <font size=-1>
316 <center><P ALIGN="CENTER">
317 Pmw 1.2 -
318 5 Aug 2003
319 - <a href="index.html">Home</a>
320 <br>Manual page last reviewed: 18 May 2002
321 </p></center>
322 </font>
323
324 </body>
325 </html>
326