Commit | Line | Data |
---|---|---|
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.Dialog 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.Dialog</h1> | |
13 | ||
14 | <center><IMG SRC=Dialog.gif ALT="" WIDTH=374 HEIGHT=162></center> | |
15 | <dl> | |
16 | <dt> <h3>Name</h3></dt><dd> | |
17 | <p>Pmw.Dialog() - | |
18 | toplevel window with button box | |
19 | </p> | |
20 | ||
21 | ||
22 | </dd> | |
23 | <dt> <h3>Inherits</h3></dt><dd> | |
24 | <a href="MegaToplevel.html">Pmw.MegaToplevel</a><br> | |
25 | </dd> | |
26 | <dt> <h3>Description</h3></dt><dd> | |
27 | <p> | |
28 | A dialog is a toplevel window composed of a button box and a child | |
29 | site area. The child site area can be used to specialise the | |
30 | megawidget by creating other widgets within it. This can be done | |
31 | by using this class directly or by deriving from it.</p> | |
32 | ||
33 | <p></p> | |
34 | ||
35 | ||
36 | </dd> | |
37 | <dt> <h3>Options</h3></dt><dd> | |
38 | Options for this megawidget and its base | |
39 | classes are described below.<p></p> | |
40 | <a name=option.activatecommand></a> | |
41 | <dl><dt> <strong>activatecommand | |
42 | </strong></dt><dd> | |
43 | If this is callable, it will be called whenever the megawidget is | |
44 | activated by a call to <code>activate()</code>. The default is <strong>None</strong>.</p> | |
45 | ||
46 | ||
47 | </dd></dl> | |
48 | <a name=option.buttonboxpos></a> | |
49 | <dl><dt> <strong>buttonboxpos | |
50 | </strong></dt><dd> | |
51 | Initialisation option. Specifies on which side of the dialog window to place the button | |
52 | 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> | |
53 | ||
54 | ||
55 | </dd></dl> | |
56 | <a name=option.buttons></a> | |
57 | <dl><dt> <strong>buttons | |
58 | </strong></dt><dd> | |
59 | This must be a tuple or a list and specifies the names on the | |
60 | buttons in the button box. The default is <strong>('OK',)</strong>.</p> | |
61 | ||
62 | ||
63 | </dd></dl> | |
64 | <a name=option.command></a> | |
65 | <dl><dt> <strong>command | |
66 | </strong></dt><dd> | |
67 | Specifies a function to call whenever a button in the button box | |
68 | is invoked or the window is deleted by the window manager. The | |
69 | function is called with a single argument, which is the name of | |
70 | the button which was invoked, or <strong>None</strong> if the window was deleted | |
71 | by the window manager.</p> | |
72 | <p> If the value of <strong>command</strong> is not callable, the default behaviour | |
73 | is to deactivate the window if it is active, or withdraw the | |
74 | window if it is not active. If it is deactivated, <code>deactivate()</code> | |
75 | is called with the button name or <strong>None</strong> as described above. The default is <strong>None</strong>.</p> | |
76 | ||
77 | ||
78 | ||
79 | </dd></dl> | |
80 | <a name=option.deactivatecommand></a> | |
81 | <dl><dt> <strong>deactivatecommand | |
82 | </strong></dt><dd> | |
83 | If this is callable, it will be called whenever the megawidget is | |
84 | deactivated by a call to <code>deactivate()</code>. The default is <strong>None</strong>.</p> | |
85 | ||
86 | ||
87 | </dd></dl> | |
88 | <a name=option.defaultbutton></a> | |
89 | <dl><dt> <strong>defaultbutton | |
90 | </strong></dt><dd> | |
91 | Specifies the default button in the button box. If the <strong><Return></strong> | |
92 | key is hit when the dialog has focus, the default button will be | |
93 | invoked. If <strong>defaultbutton</strong> is <strong>None</strong>, there will be no default | |
94 | button and hitting the <strong><Return></strong> key will have no effect. The default is <strong>None</strong>.</p> | |
95 | ||
96 | ||
97 | </dd></dl> | |
98 | <a name=option.master></a> | |
99 | <dl><dt> <strong>master | |
100 | </strong></dt><dd> | |
101 | This is used by the <code>activate()</code> method to control whether the | |
102 | window is made <em>transient</em> during modal dialogs. See the | |
103 | <code>activate()</code> method. The default is <strong>'parent'</strong>.</p> | |
104 | ||
105 | ||
106 | </dd></dl> | |
107 | <a name=option.separatorwidth></a> | |
108 | <dl><dt> <strong>separatorwidth | |
109 | </strong></dt><dd> | |
110 | Initialisation option. If this is greater than <strong>0</strong>, a separator line with the specified | |
111 | width will be created between the button box and the child site, | |
112 | as a component named <strong>separator</strong>. Since the default border of the | |
113 | button box and child site is <strong>raised</strong>, this option does not | |
114 | usually need to be set for there to be a visual separation between | |
115 | the button box and child site. The default is <strong>0</strong>.</p> | |
116 | ||
117 | ||
118 | </dd></dl> | |
119 | <a name=option.title></a> | |
120 | <dl><dt> <strong>title | |
121 | </strong></dt><dd> | |
122 | This is the title that the window manager displays in the title | |
123 | bar of the window. The default is <strong>None</strong>.</p> | |
124 | ||
125 | ||
126 | </dd></dl> | |
127 | </dd> | |
128 | <dt> <h3>Components</h3></dt><dd> | |
129 | Components created by this megawidget and its base | |
130 | classes are described below.<p></p> | |
131 | <a name=component.buttonbox></a> | |
132 | <dl><dt> <strong>buttonbox | |
133 | </strong></dt><dd> | |
134 | This is the button box containing the buttons for the dialog. By | |
135 | default it is created with the options | |
136 | <code>(hull_borderwidth = 1, hull_relief = 'raised')</code>. By default, this component is a <a href="ButtonBox.html">Pmw.ButtonBox</a>.</p> | |
137 | ||
138 | ||
139 | </dd></dl> | |
140 | <a name=component.dialogchildsite></a> | |
141 | <dl><dt> <strong>dialogchildsite | |
142 | </strong></dt><dd> | |
143 | This is the child site for the dialog, which may be used to | |
144 | specialise the megawidget by creating other widgets within it. By | |
145 | default it is created with the options | |
146 | <code>(borderwidth = 1, relief = 'raised')</code>. By default, this component is a Tkinter.Frame.</p> | |
147 | ||
148 | ||
149 | </dd></dl> | |
150 | <a name=component.hull></a> | |
151 | <dl><dt> <strong>hull | |
152 | </strong></dt><dd> | |
153 | This acts as the body for the entire megawidget. Other components | |
154 | are created as children of the hull to further specialise this | |
155 | class. By default, this component is a Tkinter.Toplevel.</p> | |
156 | ||
157 | ||
158 | </dd></dl> | |
159 | <a name=component.separator></a> | |
160 | <dl><dt> <strong>separator | |
161 | </strong></dt><dd> | |
162 | If the <strong>separatorwidth</strong> initialisation option is non-zero, the | |
163 | <strong>separator</strong> component is the line dividing the area between the | |
164 | button box and the child site. By default, this component is a Tkinter.Frame.</p> | |
165 | ||
166 | ||
167 | </dd></dl> | |
168 | </dd> | |
169 | <a name=methods></a> | |
170 | <dt> <h3>Methods</h3></dt><dd> | |
171 | Only methods specific to this megawidget are described below. | |
172 | For a description of its inherited methods, see the | |
173 | manual for its base class | |
174 | <strong><a href="MegaToplevel.html#methods">Pmw.MegaToplevel</a></strong>. | |
175 | <p></p> | |
176 | <a name=method.interior></a> | |
177 | <dl><dt> <strong>interior</strong>()</dt><dd> | |
178 | Return the child site for the dialog. This is the same as | |
179 | <code>component('dialogchildsite')</code>.</p> | |
180 | ||
181 | ||
182 | </dd></dl> | |
183 | <a name=method.invoke></a> | |
184 | <dl><dt> <strong>invoke</strong>(<em>index</em> = <strong>Pmw.DEFAULT</strong>)</dt><dd> | |
185 | Invoke the command specified by the <strong>command</strong> option as if the | |
186 | button specified by <em>index</em> had been pressed and return the | |
187 | result. <em>index</em> may have any of the forms accepted by the | |
188 | <a href="ButtonBox.html">Pmw.ButtonBox</a> <code>index()</code> method.</p> | |
189 | ||
190 | ||
191 | </dd></dl> | |
192 | </dd> | |
193 | <dt> <h3>Example</h3></dt><dd> | |
194 | The image at the top of this manual is a snapshot | |
195 | of the window (or part of the window) produced | |
196 | by the following code.<p></p> | |
197 | <pre> | |
198 | class Demo: | |
199 | def __init__(self, parent): | |
200 | # Create two buttons to launch the dialog. | |
201 | w = Tkinter.Button(parent, text = 'Show application modal dialog', | |
202 | command = self.showAppModal) | |
203 | w.pack(padx = 8, pady = 8) | |
204 | ||
205 | w = Tkinter.Button(parent, text = 'Show global modal dialog', | |
206 | command = self.showGlobalModal) | |
207 | w.pack(padx = 8, pady = 8) | |
208 | ||
209 | w = Tkinter.Button(parent, text = 'Show dialog with "no grab"', | |
210 | command = self.showDialogNoGrab) | |
211 | w.pack(padx = 8, pady = 8) | |
212 | ||
213 | w = Tkinter.Button(parent, text = | |
214 | 'Show toplevel window which\n' + | |
215 | 'will not get a busy cursor', | |
216 | command = self.showExcludedWindow) | |
217 | w.pack(padx = 8, pady = 8) | |
218 | ||
219 | # Create the dialog. | |
220 | self.dialog = Pmw.Dialog(parent, | |
221 | buttons = ('OK', 'Apply', 'Cancel', 'Help'), | |
222 | defaultbutton = 'OK', | |
223 | title = 'My dialog', | |
224 | command = self.execute) | |
225 | self.dialog.withdraw() | |
226 | ||
227 | # Add some contents to the dialog. | |
228 | w = Tkinter.Label(self.dialog.interior(), | |
229 | text = 'Pmw Dialog\n(put your widgets here)', | |
230 | background = 'black', | |
231 | foreground = 'white', | |
232 | pady = 20) | |
233 | w.pack(expand = 1, fill = 'both', padx = 4, pady = 4) | |
234 | ||
235 | # Create the window excluded from showbusycursor. | |
236 | self.excluded = Pmw.MessageDialog(parent, | |
237 | title = 'I still work', | |
238 | message_text = | |
239 | 'This window will not get\n' + | |
240 | 'a busy cursor when modal dialogs\n' + | |
241 | 'are activated. In addition,\n' + | |
242 | 'you can still interact with\n' + | |
243 | 'this window when a "no grab"\n' + | |
244 | 'modal dialog is displayed.') | |
245 | self.excluded.withdraw() | |
246 | Pmw.setbusycursorattributes(self.excluded.component('hull'), | |
247 | exclude = 1) | |
248 | ||
249 | def showAppModal(self): | |
250 | self.dialog.activate(geometry = 'centerscreenalways') | |
251 | ||
252 | def showGlobalModal(self): | |
253 | self.dialog.activate(globalMode = 1) | |
254 | ||
255 | def showDialogNoGrab(self): | |
256 | self.dialog.activate(globalMode = 'nograb') | |
257 | ||
258 | def showExcludedWindow(self): | |
259 | self.excluded.show() | |
260 | ||
261 | def execute(self, result): | |
262 | print 'You clicked on', result | |
263 | if result not in ('Apply', 'Help'): | |
264 | self.dialog.deactivate(result) | |
265 | ||
266 | </pre> | |
267 | </dd> | |
268 | </dl> | |
269 | ||
270 | <center><P ALIGN="CENTER"> | |
271 | <IMG SRC = blue_line.gif ALT = "" WIDTH=320 HEIGHT=5> | |
272 | </p></center> | |
273 | ||
274 | ||
275 | <font size=-1> | |
276 | <center><P ALIGN="CENTER"> | |
277 | Pmw 1.2 - | |
278 | 5 Aug 2003 | |
279 | - <a href="index.html">Home</a> | |
280 | <br>Manual page last reviewed: 18 May 2002 | |
281 | </p></center> | |
282 | </font> | |
283 | ||
284 | </body> | |
285 | </html> | |
286 |