Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> |
2 | <html> | |
3 | <head> | |
4 | <link rel="STYLESHEET" href="mac.css" type='text/css' /> | |
5 | <link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" /> | |
6 | <link rel='start' href='../index.html' title='Python Documentation Index' /> | |
7 | <link rel="first" href="mac.html" title='Macintosh Library Modules' /> | |
8 | <link rel='contents' href='contents.html' title="Contents" /> | |
9 | <link rel='index' href='genindex.html' title='Index' /> | |
10 | <link rel='last' href='about.html' title='About this document...' /> | |
11 | <link rel='help' href='about.html' title='About this document...' /> | |
12 | <link rel="next" href="module-FrameWork.html" /> | |
13 | <link rel="prev" href="module-findertools.html" /> | |
14 | <link rel="parent" href="macpython-modules.html" /> | |
15 | <link rel="next" href="progressbar-objects.html" /> | |
16 | <meta name='aesop' content='information' /> | |
17 | <title>2.7 EasyDialogs -- Basic Macintosh dialogs</title> | |
18 | </head> | |
19 | <body> | |
20 | <DIV CLASS="navigation"> | |
21 | <div id='top-navigation-panel' xml:id='top-navigation-panel'> | |
22 | <table align="center" width="100%" cellpadding="0" cellspacing="2"> | |
23 | <tr> | |
24 | <td class='online-navigation'><a rel="prev" title="2.6 findertools " | |
25 | href="module-findertools.html"><img src='../icons/previous.png' | |
26 | border='0' height='32' alt='Previous Page' width='32' /></A></td> | |
27 | <td class='online-navigation'><a rel="parent" title="2. MacPython Modules" | |
28 | href="macpython-modules.html"><img src='../icons/up.png' | |
29 | border='0' height='32' alt='Up One Level' width='32' /></A></td> | |
30 | <td class='online-navigation'><a rel="next" title="2.7.1 ProgressBar Objects" | |
31 | href="progressbar-objects.html"><img src='../icons/next.png' | |
32 | border='0' height='32' alt='Next Page' width='32' /></A></td> | |
33 | <td align="center" width="100%">Macintosh Library Modules</td> | |
34 | <td class='online-navigation'><a rel="contents" title="Table of Contents" | |
35 | href="contents.html"><img src='../icons/contents.png' | |
36 | border='0' height='32' alt='Contents' width='32' /></A></td> | |
37 | <td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png' | |
38 | border='0' height='32' alt='Module Index' width='32' /></a></td> | |
39 | <td class='online-navigation'><a rel="index" title="Index" | |
40 | href="genindex.html"><img src='../icons/index.png' | |
41 | border='0' height='32' alt='Index' width='32' /></A></td> | |
42 | </tr></table> | |
43 | <div class='online-navigation'> | |
44 | <b class="navlabel">Previous:</b> | |
45 | <a class="sectref" rel="prev" href="module-findertools.html">2.6 findertools </A> | |
46 | <b class="navlabel">Up:</b> | |
47 | <a class="sectref" rel="parent" href="macpython-modules.html">2. MacPython Modules</A> | |
48 | <b class="navlabel">Next:</b> | |
49 | <a class="sectref" rel="next" href="progressbar-objects.html">2.7.1 ProgressBar Objects</A> | |
50 | </div> | |
51 | <hr /></div> | |
52 | </DIV> | |
53 | <!--End of Navigation Panel--> | |
54 | ||
55 | <H1><A NAME="SECTION004700000000000000000"> | |
56 | 2.7 <tt class="module">EasyDialogs</tt> -- | |
57 | Basic Macintosh dialogs</A> | |
58 | </H1> | |
59 | ||
60 | <P> | |
61 | <A NAME="module-EasyDialogs"></A> | |
62 | <p class="availability">Availability: <span | |
63 | class="platform">Macintosh</span>.</p> | |
64 | ||
65 | <P> | |
66 | The <tt class="module">EasyDialogs</tt> module contains some simple dialogs for the | |
67 | Macintosh. All routines take an optional resource ID parameter <var>id</var> | |
68 | with which one can override the <tt class="constant">DLOG</tt> resource used for the | |
69 | dialog, provided that the dialog items correspond (both type and item | |
70 | number) to those in the default <tt class="constant">DLOG</tt> resource. See source | |
71 | code for details. | |
72 | ||
73 | <P> | |
74 | The <tt class="module">EasyDialogs</tt> module defines the following functions: | |
75 | ||
76 | <P> | |
77 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
78 | <td><nobr><b><tt id='l2h-81' xml:id='l2h-81' class="function">Message</tt></b>(</nobr></td> | |
79 | <td><var>str</var><big>[</big><var>, id</var><big>[</big><var>, ok</var><big>]</big><var></var><big>]</big><var></var>)</td></tr></table></dt> | |
80 | <dd> | |
81 | Displays a modal dialog with the message text <var>str</var>, which should be | |
82 | at most 255 characters long. The button text defaults to ``OK'', but is | |
83 | set to the string argument <var>ok</var> if the latter is supplied. Control | |
84 | is returned when the user clicks the ``OK'' button. | |
85 | </dl> | |
86 | ||
87 | <P> | |
88 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
89 | <td><nobr><b><tt id='l2h-82' xml:id='l2h-82' class="function">AskString</tt></b>(</nobr></td> | |
90 | <td><var>prompt</var><big>[</big><var>, default</var><big>[</big><var>, | |
91 | id</var><big>[</big><var>, ok</var><big>[</big><var>, cancel</var><big>]</big><var></var><big>]</big><var></var><big>]</big><var></var><big>]</big><var></var>)</td></tr></table></dt> | |
92 | <dd> | |
93 | Asks the user to input a string value via a modal dialog. <var>prompt</var> | |
94 | is the prompt message, and the optional <var>default</var> supplies the | |
95 | initial value for the string (otherwise <code>""</code> is used). The text of | |
96 | the ``OK'' and ``Cancel'' buttons can be changed with the <var>ok</var> and | |
97 | <var>cancel</var> arguments. All strings can be at most 255 bytes long. | |
98 | <tt class="function">AskString()</tt> returns the string entered or <tt class="constant">None</tt> | |
99 | in case the user cancelled. | |
100 | </dl> | |
101 | ||
102 | <P> | |
103 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
104 | <td><nobr><b><tt id='l2h-83' xml:id='l2h-83' class="function">AskPassword</tt></b>(</nobr></td> | |
105 | <td><var>prompt</var><big>[</big><var>, default</var><big>[</big><var>, | |
106 | id</var><big>[</big><var>, ok</var><big>[</big><var>, cancel</var><big>]</big><var></var><big>]</big><var></var><big>]</big><var></var><big>]</big><var></var>)</td></tr></table></dt> | |
107 | <dd> | |
108 | Asks the user to input a string value via a modal dialog. Like | |
109 | <tt class="function">AskString()</tt>, but with the text shown as bullets. The | |
110 | arguments have the same meaning as for <tt class="function">AskString()</tt>. | |
111 | </dl> | |
112 | ||
113 | <P> | |
114 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
115 | <td><nobr><b><tt id='l2h-84' xml:id='l2h-84' class="function">AskYesNoCancel</tt></b>(</nobr></td> | |
116 | <td><var>question</var><big>[</big><var>, default</var><big>[</big><var>, | |
117 | yes</var><big>[</big><var>, no</var><big>[</big><var>, cancel</var><big>[</big><var>, id</var><big>]</big><var></var><big>]</big><var></var><big>]</big><var></var><big>]</big><var></var><big>]</big><var></var>)</td></tr></table></dt> | |
118 | <dd> | |
119 | Presents a dialog with prompt <var>question</var> and three buttons labelled | |
120 | ``Yes'', ``No'', and ``Cancel''. Returns <code>1</code> for ``Yes'', <code>0</code> | |
121 | for ``No'' and <code>-1</code> for ``Cancel''. The value of <var>default</var> (or | |
122 | <code>0</code> if <var>default</var> is not supplied) is returned when the | |
123 | <kbd>RETURN</kbd> key is pressed. The text of the buttons can be changed with | |
124 | the <var>yes</var>, <var>no</var>, and <var>cancel</var> arguments; to prevent a button | |
125 | from appearing, supply <code>""</code> for the corresponding argument. | |
126 | </dl> | |
127 | ||
128 | <P> | |
129 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
130 | <td><nobr><b><tt id='l2h-85' xml:id='l2h-85' class="function">ProgressBar</tt></b>(</nobr></td> | |
131 | <td><var></var><big>[</big><var>title</var><big>[</big><var>, maxval</var><big>[</big><var>, | |
132 | label</var><big>[</big><var>, id</var><big>]</big><var></var><big>]</big><var></var><big>]</big><var></var><big>]</big><var></var>)</td></tr></table></dt> | |
133 | <dd> | |
134 | Displays a modeless progress-bar dialog. This is the constructor for the | |
135 | <tt class="class">ProgressBar</tt> class described below. <var>title</var> is the text | |
136 | string displayed (default ``Working...''), <var>maxval</var> is the value at | |
137 | which progress is complete (default <code>0</code>, indicating that an | |
138 | indeterminate amount of work remains to be done), and <var>label</var> is | |
139 | the text that is displayed above the progress bar itself. | |
140 | </dl> | |
141 | ||
142 | <P> | |
143 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
144 | <td><nobr><b><tt id='l2h-86' xml:id='l2h-86' class="function">GetArgv</tt></b>(</nobr></td> | |
145 | <td><var></var><big>[</big><var>optionlist</var><big>[</big><var> | |
146 | commandlist</var><big>[</big><var>, addoldfile</var><big>[</big><var>, addnewfile</var><big>[</big><var>, | |
147 | addfolder</var><big>[</big><var>, id</var><big>]</big><var></var><big>]</big><var></var><big>]</big><var></var><big>]</big><var></var><big>]</big><var></var><big>]</big><var></var>)</td></tr></table></dt> | |
148 | <dd> | |
149 | Displays a dialog which aids the user in constructing a command-line | |
150 | argument list. Returns the list in <code>sys.argv</code> format, suitable for | |
151 | passing as an argument to <tt class="function">getopt.getopt()</tt>. <var>addoldfile</var>, | |
152 | <var>addnewfile</var>, and <var>addfolder</var> are boolean arguments. When | |
153 | nonzero, they enable the user to insert into the command line paths to | |
154 | an existing file, a (possibly) not-yet-existent file, and a folder, | |
155 | respectively. (Note: Option arguments must appear in the command line | |
156 | before file and folder arguments in order to be recognized by | |
157 | <tt class="function">getopt.getopt()</tt>.) Arguments containing spaces can be | |
158 | specified by enclosing them within single or double quotes. A | |
159 | <tt class="exception">SystemExit</tt> exception is raised if the user presses the | |
160 | ``Cancel'' button. | |
161 | ||
162 | <P> | |
163 | <var>optionlist</var> is a list that determines a popup menu from which the | |
164 | allowed options are selected. Its items can take one of two forms: | |
165 | <var>optstr</var> or <code>(<var>optstr</var>, <var>descr</var>)</code>. When present, | |
166 | <var>descr</var> is a short descriptive string that is displayed in the | |
167 | dialog while this option is selected in the popup menu. The | |
168 | correspondence between <var>optstr</var>s and command-line arguments is: | |
169 | ||
170 | <P> | |
171 | <div class="center"><table class="realtable"> | |
172 | <thead> | |
173 | <tr> | |
174 | <th class="left" ><var>optstr</var> format</th> | |
175 | <th class="left" >Command-line format</th> | |
176 | </tr> | |
177 | </thead> | |
178 | <tbody> | |
179 | <tr><td class="left" valign="baseline"><code>x</code></td> | |
180 | <td class="left" ><b class="programopt">-x</b> (short option)</td></tr> | |
181 | <tr><td class="left" valign="baseline"><code>x:</code> or <code>x=</code></td> | |
182 | <td class="left" ><b class="programopt">-x</b> (short option with value)</td></tr> | |
183 | <tr><td class="left" valign="baseline"><code>xyz</code></td> | |
184 | <td class="left" ><b class="programopt">--xyz</b> (long option)</td></tr> | |
185 | <tr><td class="left" valign="baseline"><code>xyz:</code> or <code>xyz=</code></td> | |
186 | <td class="left" ><b class="programopt">--xyz</b> (long option with value)</td></tr></tbody> | |
187 | </table></div> | |
188 | ||
189 | <P> | |
190 | <var>commandlist</var> is a list of items of the form <var>cmdstr</var> or | |
191 | <code>(<var>cmdstr</var>, <var>descr</var>)</code>, where <var>descr</var> is as above. The | |
192 | <var>cmdstr</var>s will appear in a popup menu. When chosen, the text of | |
193 | <var>cmdstr</var> will be appended to the command line as is, except that a | |
194 | trailing "<tt class="character">:</tt>" or "<tt class="character">=</tt>" (if present) will be trimmed | |
195 | off. | |
196 | ||
197 | <P> | |
198 | ||
199 | <span class="versionnote">New in version 2.0.</span> | |
200 | ||
201 | </dl> | |
202 | ||
203 | <P> | |
204 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
205 | <td><nobr><b><tt id='l2h-87' xml:id='l2h-87' class="function">AskFileForOpen</tt></b>(</nobr></td> | |
206 | <td><var> | |
207 | </var><big>[</big><var>message</var><big>]</big><var> | |
208 | </var><big>[</big><var>, typeList</var><big>]</big><var> | |
209 | </var><big>[</big><var>, defaultLocation</var><big>]</big><var> | |
210 | </var><big>[</big><var>, defaultOptionFlags</var><big>]</big><var> | |
211 | </var><big>[</big><var>, location</var><big>]</big><var> | |
212 | </var><big>[</big><var>, clientName</var><big>]</big><var> | |
213 | </var><big>[</big><var>, windowTitle</var><big>]</big><var> | |
214 | </var><big>[</big><var>, actionButtonLabel</var><big>]</big><var> | |
215 | </var><big>[</big><var>, cancelButtonLabel</var><big>]</big><var> | |
216 | </var><big>[</big><var>, preferenceKey</var><big>]</big><var> | |
217 | </var><big>[</big><var>, popupExtension</var><big>]</big><var> | |
218 | </var><big>[</big><var>, eventProc</var><big>]</big><var> | |
219 | </var><big>[</big><var>, previewProc</var><big>]</big><var> | |
220 | </var><big>[</big><var>, filterProc</var><big>]</big><var> | |
221 | </var><big>[</big><var>, wanted</var><big>]</big><var> | |
222 | </var>)</td></tr></table></dt> | |
223 | <dd> | |
224 | Post a dialog asking the user for a file to open, and return the file | |
225 | selected or <tt class="constant">None</tt> if the user cancelled. | |
226 | <var>message</var> is a text message to display, | |
227 | <var>typeList</var> is a list of 4-char filetypes allowable, | |
228 | <var>defaultLocation</var> is the pathname, <tt class="class">FSSpec</tt> or <tt class="class">FSRef</tt> | |
229 | of the folder to show initially, | |
230 | <var>location</var> is the <code>(x, y)</code> position on the screen where the | |
231 | dialog is shown, | |
232 | <var>actionButtonLabel</var> is a string to show instead of ``Open'' in the | |
233 | OK button, | |
234 | <var>cancelButtonLabel</var> is a string to show instead of ``Cancel'' in the | |
235 | cancel button, | |
236 | <var>wanted</var> is the type of value wanted as a return: <tt class="class">str</tt>, | |
237 | <tt class="class">unicode</tt>, <tt class="class">FSSpec</tt>, <tt class="class">FSRef</tt> and subtypes thereof are | |
238 | acceptable. | |
239 | ||
240 | <P> | |
241 | <a id='l2h-90' xml:id='l2h-90'></a> | |
242 | For a description of the other arguments please see the Apple Navigation | |
243 | Services documentation and the <tt class="module">EasyDialogs</tt> source code. | |
244 | </dl> | |
245 | ||
246 | <P> | |
247 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
248 | <td><nobr><b><tt id='l2h-88' xml:id='l2h-88' class="function">AskFileForSave</tt></b>(</nobr></td> | |
249 | <td><var> | |
250 | </var><big>[</big><var>message</var><big>]</big><var> | |
251 | </var><big>[</big><var>, savedFileName</var><big>]</big><var> | |
252 | </var><big>[</big><var>, defaultLocation</var><big>]</big><var> | |
253 | </var><big>[</big><var>, defaultOptionFlags</var><big>]</big><var> | |
254 | </var><big>[</big><var>, location</var><big>]</big><var> | |
255 | </var><big>[</big><var>, clientName</var><big>]</big><var> | |
256 | </var><big>[</big><var>, windowTitle</var><big>]</big><var> | |
257 | </var><big>[</big><var>, actionButtonLabel</var><big>]</big><var> | |
258 | </var><big>[</big><var>, cancelButtonLabel</var><big>]</big><var> | |
259 | </var><big>[</big><var>, preferenceKey</var><big>]</big><var> | |
260 | </var><big>[</big><var>, popupExtension</var><big>]</big><var> | |
261 | </var><big>[</big><var>, fileType</var><big>]</big><var> | |
262 | </var><big>[</big><var>, fileCreator</var><big>]</big><var> | |
263 | </var><big>[</big><var>, eventProc</var><big>]</big><var> | |
264 | </var><big>[</big><var>, wanted</var><big>]</big><var> | |
265 | </var>)</td></tr></table></dt> | |
266 | <dd> | |
267 | Post a dialog asking the user for a file to save to, and return the | |
268 | file selected or <tt class="constant">None</tt> if the user cancelled. | |
269 | <var>savedFileName</var> is the default for the file name to save to (the | |
270 | return value). See <tt class="function">AskFileForOpen()</tt> for a description of | |
271 | the other arguments. | |
272 | </dl> | |
273 | ||
274 | <P> | |
275 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
276 | <td><nobr><b><tt id='l2h-89' xml:id='l2h-89' class="function">AskFolder</tt></b>(</nobr></td> | |
277 | <td><var> | |
278 | </var><big>[</big><var>message</var><big>]</big><var> | |
279 | </var><big>[</big><var>, defaultLocation</var><big>]</big><var> | |
280 | </var><big>[</big><var>, defaultOptionFlags</var><big>]</big><var> | |
281 | </var><big>[</big><var>, location</var><big>]</big><var> | |
282 | </var><big>[</big><var>, clientName</var><big>]</big><var> | |
283 | </var><big>[</big><var>, windowTitle</var><big>]</big><var> | |
284 | </var><big>[</big><var>, actionButtonLabel</var><big>]</big><var> | |
285 | </var><big>[</big><var>, cancelButtonLabel</var><big>]</big><var> | |
286 | </var><big>[</big><var>, preferenceKey</var><big>]</big><var> | |
287 | </var><big>[</big><var>, popupExtension</var><big>]</big><var> | |
288 | </var><big>[</big><var>, eventProc</var><big>]</big><var> | |
289 | </var><big>[</big><var>, filterProc</var><big>]</big><var> | |
290 | </var><big>[</big><var>, wanted</var><big>]</big><var> | |
291 | </var>)</td></tr></table></dt> | |
292 | <dd> | |
293 | Post a dialog asking the user to select a folder, and return the | |
294 | folder selected or <tt class="constant">None</tt> if the user cancelled. See | |
295 | <tt class="function">AskFileForOpen()</tt> for a description of the arguments. | |
296 | </dl> | |
297 | ||
298 | <P> | |
299 | <div class="seealso"> | |
300 | <p class="heading">See Also:</p> | |
301 | ||
302 | <dl compact="compact" class="seetitle"> | |
303 | <dt><em class="citetitle"><a href="http://developer.apple.com/documentation/Carbon/Reference/Navigation_Services_Ref/" | |
304 | >Navigation Services Reference</a></em></dt> | |
305 | <dd>Programmer's reference documentation | |
306 | for the Navigation Services, a part of the Carbon framework.</dd> | |
307 | </dl> | |
308 | </div> | |
309 | ||
310 | <P> | |
311 | ||
312 | <p><br /></p><hr class='online-navigation' /> | |
313 | <div class='online-navigation'> | |
314 | <!--Table of Child-Links--> | |
315 | <A NAME="CHILD_LINKS"><STRONG>Subsections</STRONG></a> | |
316 | ||
317 | <UL CLASS="ChildLinks"> | |
318 | <LI><A href="progressbar-objects.html">2.7.1 ProgressBar Objects</a> | |
319 | </ul> | |
320 | <!--End of Table of Child-Links--> | |
321 | </div> | |
322 | ||
323 | <DIV CLASS="navigation"> | |
324 | <div class='online-navigation'> | |
325 | <p></p><hr /> | |
326 | <table align="center" width="100%" cellpadding="0" cellspacing="2"> | |
327 | <tr> | |
328 | <td class='online-navigation'><a rel="prev" title="2.6 findertools " | |
329 | href="module-findertools.html"><img src='../icons/previous.png' | |
330 | border='0' height='32' alt='Previous Page' width='32' /></A></td> | |
331 | <td class='online-navigation'><a rel="parent" title="2. MacPython Modules" | |
332 | href="macpython-modules.html"><img src='../icons/up.png' | |
333 | border='0' height='32' alt='Up One Level' width='32' /></A></td> | |
334 | <td class='online-navigation'><a rel="next" title="2.7.1 ProgressBar Objects" | |
335 | href="progressbar-objects.html"><img src='../icons/next.png' | |
336 | border='0' height='32' alt='Next Page' width='32' /></A></td> | |
337 | <td align="center" width="100%">Macintosh Library Modules</td> | |
338 | <td class='online-navigation'><a rel="contents" title="Table of Contents" | |
339 | href="contents.html"><img src='../icons/contents.png' | |
340 | border='0' height='32' alt='Contents' width='32' /></A></td> | |
341 | <td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png' | |
342 | border='0' height='32' alt='Module Index' width='32' /></a></td> | |
343 | <td class='online-navigation'><a rel="index" title="Index" | |
344 | href="genindex.html"><img src='../icons/index.png' | |
345 | border='0' height='32' alt='Index' width='32' /></A></td> | |
346 | </tr></table> | |
347 | <div class='online-navigation'> | |
348 | <b class="navlabel">Previous:</b> | |
349 | <a class="sectref" rel="prev" href="module-findertools.html">2.6 findertools </A> | |
350 | <b class="navlabel">Up:</b> | |
351 | <a class="sectref" rel="parent" href="macpython-modules.html">2. MacPython Modules</A> | |
352 | <b class="navlabel">Next:</b> | |
353 | <a class="sectref" rel="next" href="progressbar-objects.html">2.7.1 ProgressBar Objects</A> | |
354 | </div> | |
355 | </div> | |
356 | <hr /> | |
357 | <span class="release-info">Release 2.4.2, documentation updated on 28 September 2005.</span> | |
358 | </DIV> | |
359 | <!--End of Navigation Panel--> | |
360 | <ADDRESS> | |
361 | See <i><a href="about.html">About this document...</a></i> for information on suggesting changes. | |
362 | </ADDRESS> | |
363 | </BODY> | |
364 | </HTML> |