openfile(): Go back to opening the files in text mode. This undoes
[python/dscho.git] / Doc / mac / libmacui.tex
bloba3018ec107c4ed6d043d96a0a02e8ee97127a43a
1 \section{\module{EasyDialogs} ---
2 Basic Macintosh dialogs}
4 \declaremodule{standard}{EasyDialogs}
5 \platform{Mac}
6 \modulesynopsis{Basic Macintosh dialogs.}
8 The \module{EasyDialogs} module contains some simple dialogs for the
9 Macintosh. All routines take an optional resource ID parameter \var{id}
10 with which one can override the \constant{DLOG} resource used for the
11 dialog, provided that the dialog items correspond (both type and item
12 number) to those in the default \constant{DLOG} resource. See source
13 code for details.
15 The \module{EasyDialogs} module defines the following functions:
18 \begin{funcdesc}{Message}{str\optional{, id\optional{, ok=None}}}
19 Displays a modal dialog with the message text \var{str}, which should be
20 at most 255 characters long. The button text defaults to ``OK'', but is
21 set to the string argument \var{ok} if the latter is supplied. Control
22 is returned when the user clicks the ``OK'' button.
23 \end{funcdesc}
26 \begin{funcdesc}{AskString}{prompt\optional{, default\optional{,
27 id\optional{, ok\optional{, cancel}}}}}
28 Asks the user to input a string value via a modal dialog. \var{prompt}
29 is the prompt message, and the optional \var{default} supplies the
30 initial value for the string (otherwise \code{""} is used). The text of
31 the ``OK'' and ``Cancel'' buttons can be changed with the \var{ok} and
32 \var{cancel} arguments. All strings can be at most 255 bytes long.
33 \function{AskString()} returns the string entered or \code{None} in case
34 the user cancelled.
35 \end{funcdesc}
38 \begin{funcdesc}{AskPassword}{prompt\optional{, default\optional{,
39 id\optional{, ok\optional{, cancel}}}}}
40 Asks the user to input a string value via a modal dialog. Like
41 \function{AskString()}, but with the text shown as bullets. The
42 arguments have the same meaning as for \function{AskString()}.
43 \end{funcdesc}
46 \begin{funcdesc}{AskYesNoCancel}{question\optional{, default\optional{,
47 yes\optional{, no\optional{, cancel\optional{, id}}}}}}
48 Presents a dialog with prompt \var{question} and three buttons labelled
49 ``Yes'', ``No'', and ``Cancel''. Returns \code{1} for ``Yes'', \code{0}
50 for ``No'' and \code{-1} for ``Cancel''. The value of \var{default} (or
51 \code{0} if \var{default} is not supplied) is returned when the
52 \kbd{RETURN} key is pressed. The text of the buttons can be changed with
53 the \var{yes}, \var{no}, and \var{cancel} arguments; to prevent a button
54 from appearing, supply \code{""} for the corresponding argument.
55 \end{funcdesc}
58 \begin{funcdesc}{ProgressBar}{\optional{title\optional{, maxval\optional{,
59 label\optional{, id}}}}}
60 Displays a modeless progress-bar dialog. This is the constructor for the
61 \class{ProgressBar} class described below. \var{title} is the text
62 string displayed (default ``Working...''), \var{maxval} is the value at
63 which progress is complete (default \code{0}, indicating that an
64 indeterminate amount of work remains to be done), and \var{label} is
65 the text that is displayed above the progress bar itself.
66 \end{funcdesc}
69 \begin{funcdesc}{GetArgv}{\optional{optionlist\optional{
70 commandlist\optional{, addoldfile\optional{, addnewfile\optional{,
71 addfolder\optional{, id}}}}}}}
72 Displays a dialog which aids the user in constructing a command-line
73 argument list. Returns the list in \code{sys.argv} format, suitable for
74 passing as an argument to \function{getopt.getopt()}. \var{addoldfile},
75 \var{addnewfile}, and \var{addfolder} are boolean arguments. When
76 nonzero, they enable the user to insert into the command line paths to
77 an existing file, a (possibly) not-yet-existent file, and a folder,
78 respectively. (Note: Option arguments must appear in the command line
79 before file and folder arguments in order to be recognized by
80 \function{getopt.getopt()}.) Arguments containing spaces can be
81 specified by enclosing them within single or double quotes. A
82 \exception{SystemExit} exception is raised if the user presses the
83 ``Cancel'' button.
85 \var{optionlist} is a list that determines a popup menu from which the
86 allowed options are selected. Its items can take one of two forms:
87 \var{optstr} or \code{(\var{optstr}, \var{descr})}. When present,
88 \var{descr} is a short descriptive string that is displayed in the
89 dialog while this option is selected in the popup menu. The
90 correspondence between \var{optstr}s and command-line arguments is:
92 \begin{tableii}{l|l}{textrm}{\var{optstr} format}{Command-line format}
93 \lineii{\code{x}}
94 {\programopt{-x} (short option)}
95 \lineii{\code{x:} or \code{x=}}
96 {\programopt{-x} (short option with value)}
97 \lineii{\code{xyz}}
98 {\longprogramopt{xyz} (long option)}
99 \lineii{\code{xyz:} or \code{xyz=}}
100 {\longprogramopt{xyz} (long option with value)}
101 \end{tableii}
103 \var{commandlist} is a list of items of the form \var{cmdstr} or
104 \code{(\var{cmdstr}, \var{descr})}, where \var{descr} is as above. The
105 \var{cmdstr}s will appear in a popup menu. When chosen, the text of
106 \var{cmdstr} will be appended to the command line as is, except that a
107 trailing \character{:} or \character{=} (if present) will be trimmed
108 off.
110 \versionadded{2.0}
111 \end{funcdesc}
115 \subsection{ProgressBar Objects \label{progressbar-objects}}
117 \class{ProgressBar} objects provide support for modeless progress-bar
118 dialogs. Both determinate (thermometer style) and indeterminate
119 (barber-pole style) progress bars are supported. The bar will be
120 determinate if its maximum value is greater than zero; otherwise it
121 will be indeterminate.
122 \versionchanged[Support for indeterminate-style progress bars was
123 added]{2.2}
125 The dialog is displayed immediately after creation. If the dialog's
126 ``Cancel'' button is pressed, or if \kbd{Cmd-.} or \kbd{ESC} is typed,
127 the dialog window is hidden and \exception{KeyboardInterrupt} is
128 raised (but note that this response does not occur until the progress
129 bar is next updated, typically via a call to \method{inc()} or
130 \method{set()}). Otherwise, the bar remains visible until the
131 \class{ProgressBar} object is discarded.
133 \class{ProgressBar} objects possess the following attributes and
134 methods:
136 \begin{memberdesc}[ProgressBar]{curval}
137 The current value (of type integer or long integer) of the progress
138 bar. The normal access methods coerce \member{curval} between
139 \code{0} and \member{maxval}. This attribute should not be altered
140 directly.
141 \end{memberdesc}
143 \begin{memberdesc}[ProgressBar]{maxval}
144 The maximum value (of type integer or long integer) of the progress
145 bar; the progress bar (thermometer style) is full when \member{curval}
146 equals \member{maxval}. If \member{maxval} is \code{0}, the bar will
147 be indeterminate (barber-pole). This attribute should not be altered
148 directly.
149 \end{memberdesc}
151 \begin{methoddesc}[ProgressBar]{title}{\optional{newstr}}
152 Sets the text in the title bar of the progress dialog to
153 \var{newstr}.
154 \end{methoddesc}
156 \begin{methoddesc}[ProgressBar]{label}{\optional{newstr}}
157 Sets the text in the progress box of the progress dialog to
158 \var{newstr}.
159 \end{methoddesc}
161 \begin{methoddesc}[ProgressBar]{set}{value\optional{, max}}
162 Sets the progress bar's \member{curval} to \var{value}, and also
163 \member{maxval} to \var{max} if the latter is provided. \var{value}
164 is first coerced between 0 and \member{maxval}. The thermometer bar
165 is updated to reflect the changes, including a change from
166 indeterminate to determinate or vice versa.
167 \end{methoddesc}
169 \begin{methoddesc}[ProgressBar]{inc}{\optional{n}}
170 Increments the progress bar's \member{curval} by \var{n}, or by \code{1}
171 if \var{n} is not provided. (Note that \var{n} may be negative, in
172 which case the effect is a decrement.) The progress bar is updated to
173 reflect the change. If the bar is indeterminate, this causes one
174 ``spin'' of the barber pole. The resulting \member{curval} is coerced
175 between 0 and \member{maxval} if incrementing causes it to fall
176 outside this range.
177 \end{methoddesc}