Fixed: #2914 (RFE for UTC support in TimedRotatingFileHandler) and #2929 (wrong filen...
[python.git] / Doc / library / easydialogs.rst
blobdbda57fba13ec4135e32119e6e3ce8b82beeffbe
2 :mod:`EasyDialogs` --- Basic Macintosh dialogs
3 ==============================================
5 .. module:: EasyDialogs
6    :platform: Mac
7    :synopsis: Basic Macintosh dialogs.
8    :deprecated:
11 The :mod:`EasyDialogs` module contains some simple dialogs for the Macintosh.
12 All routines take an optional resource ID parameter *id* with which one can
13 override the :const:`DLOG` resource used for the dialog, provided that the
14 dialog items correspond (both type and item number) to those in the default
15 :const:`DLOG` resource. See source code for details.
17 .. warning::
19    This module is removed in 3.0.
22 The :mod:`EasyDialogs` module defines the following functions:
25 .. function:: Message(str[, id[, ok]])
27    Displays a modal dialog with the message text *str*, which should be at most 255
28    characters long. The button text defaults to "OK", but is set to the string
29    argument *ok* if the latter is supplied. Control is returned when the user
30    clicks the "OK" button.
33 .. function:: AskString(prompt[, default[, id[, ok[, cancel]]]])
35    Asks the user to input a string value via a modal dialog. *prompt* is the prompt
36    message, and the optional *default* supplies the initial value for the string
37    (otherwise ``""`` is used). The text of the "OK" and "Cancel" buttons can be
38    changed with the *ok* and *cancel* arguments. All strings can be at most 255
39    bytes long. :func:`AskString` returns the string entered or :const:`None` in
40    case the user cancelled.
43 .. function:: AskPassword(prompt[, default[, id[, ok[, cancel]]]])
45    Asks the user to input a string value via a modal dialog. Like
46    :func:`AskString`, but with the text shown as bullets. The arguments have the
47    same meaning as for :func:`AskString`.
50 .. function:: AskYesNoCancel(question[, default[, yes[, no[, cancel[, id]]]]])
52    Presents a dialog with prompt *question* and three buttons labelled "Yes", "No",
53    and "Cancel". Returns ``1`` for "Yes", ``0`` for "No" and ``-1`` for "Cancel".
54    The value of *default* (or ``0`` if *default* is not supplied) is returned when
55    the :kbd:`RETURN` key is pressed. The text of the buttons can be changed with
56    the *yes*, *no*, and *cancel* arguments; to prevent a button from appearing,
57    supply ``""`` for the corresponding argument.
60 .. function:: ProgressBar([title[, maxval[, label[, id]]]])
62    Displays a modeless progress-bar dialog. This is the constructor for the
63    :class:`ProgressBar` class described below. *title* is the text string displayed
64    (default "Working..."), *maxval* is the value at which progress is complete
65    (default ``0``, indicating that an indeterminate amount of work remains to be
66    done), and *label* is the text that is displayed above the progress bar itself.
69 .. function:: GetArgv([optionlist[ commandlist[, addoldfile[, addnewfile[, addfolder[, id]]]]]])
71    Displays a dialog which aids the user in constructing a command-line argument
72    list.  Returns the list in ``sys.argv`` format, suitable for passing as an
73    argument to :func:`getopt.getopt`.  *addoldfile*, *addnewfile*, and *addfolder*
74    are boolean arguments.  When nonzero, they enable the user to insert into the
75    command line paths to an existing file, a (possibly) not-yet-existent file, and
76    a folder, respectively.  (Note: Option arguments must appear in the command line
77    before file and folder arguments in order to be recognized by
78    :func:`getopt.getopt`.)  Arguments containing spaces can be specified by
79    enclosing them within single or double quotes.  A :exc:`SystemExit` exception is
80    raised if the user presses the "Cancel" button.
82    *optionlist* is a list that determines a popup menu from which the allowed
83    options are selected.  Its items can take one of two forms: *optstr* or
84    ``(optstr, descr)``.  When present, *descr* is a short descriptive string that
85    is displayed in the dialog while this option is selected in the popup menu.  The
86    correspondence between *optstr*\s and command-line arguments is:
88    +----------------------+------------------------------------------+
89    | *optstr* format      | Command-line format                      |
90    +======================+==========================================+
91    | ``x``                | :option:`-x` (short option)              |
92    +----------------------+------------------------------------------+
93    | ``x:`` or ``x=``     | :option:`-x` (short option with value)   |
94    +----------------------+------------------------------------------+
95    | ``xyz``              | :option:`--xyz` (long option)            |
96    +----------------------+------------------------------------------+
97    | ``xyz:`` or ``xyz=`` | :option:`--xyz` (long option with value) |
98    +----------------------+------------------------------------------+
100    *commandlist* is a list of items of the form *cmdstr* or ``(cmdstr, descr)``,
101    where *descr* is as above.  The *cmdstr*s will appear in a popup menu.  When
102    chosen, the text of *cmdstr* will be appended to the command line as is, except
103    that a trailing ``':'`` or ``'='`` (if present) will be trimmed off.
105    .. versionadded:: 2.0
108 .. function:: AskFileForOpen( [message] [, typeList] [, defaultLocation] [, defaultOptionFlags] [, location] [, clientName] [, windowTitle] [, actionButtonLabel] [, cancelButtonLabel] [, preferenceKey] [, popupExtension] [, eventProc] [, previewProc] [, filterProc] [, wanted] )
110    Post a dialog asking the user for a file to open, and return the file selected
111    or :const:`None` if the user cancelled. *message* is a text message to display,
112    *typeList* is a list of 4-char filetypes allowable, *defaultLocation* is the
113    pathname, :class:`FSSpec` or :class:`FSRef` of the folder to show initially,
114    *location* is the ``(x, y)`` position on the screen where the dialog is shown,
115    *actionButtonLabel* is a string to show instead of "Open" in the OK button,
116    *cancelButtonLabel* is a string to show instead of "Cancel" in the cancel
117    button, *wanted* is the type of value wanted as a return: :class:`str`,
118    :class:`unicode`, :class:`FSSpec`, :class:`FSRef` and subtypes thereof are
119    acceptable.
121    .. index:: single: Navigation Services
123    For a description of the other arguments please see the Apple Navigation
124    Services documentation and the :mod:`EasyDialogs` source code.
127 .. function:: AskFileForSave( [message] [, savedFileName] [, defaultLocation] [, defaultOptionFlags] [, location] [, clientName] [, windowTitle] [, actionButtonLabel] [, cancelButtonLabel] [, preferenceKey] [, popupExtension] [, fileType] [, fileCreator] [, eventProc] [, wanted] )
129    Post a dialog asking the user for a file to save to, and return the file
130    selected or :const:`None` if the user cancelled. *savedFileName* is the default
131    for the file name to save to (the return value). See :func:`AskFileForOpen` for
132    a description of the other arguments.
135 .. function:: AskFolder( [message] [, defaultLocation] [, defaultOptionFlags] [, location] [, clientName] [, windowTitle] [, actionButtonLabel] [, cancelButtonLabel] [, preferenceKey] [, popupExtension] [, eventProc] [, filterProc] [, wanted] )
137    Post a dialog asking the user to select a folder, and return the folder selected
138    or :const:`None` if the user cancelled. See :func:`AskFileForOpen` for a
139    description of the arguments.
142 .. seealso::
144    `Navigation Services Reference <http://developer.apple.com/documentation/Carbon/Reference/Navigation_Services_Ref/>`_
145       Programmer's reference documentation for the Navigation Services, a part of the
146       Carbon framework.
149 .. _progressbar-objects:
151 ProgressBar Objects
152 -------------------
154 :class:`ProgressBar` objects provide support for modeless progress-bar dialogs.
155 Both determinate (thermometer style) and indeterminate (barber-pole style)
156 progress bars are supported.  The bar will be determinate if its maximum value
157 is greater than zero; otherwise it will be indeterminate.
159 .. versionchanged:: 2.2
160    Support for indeterminate-style progress bars was added.
162 The dialog is displayed immediately after creation. If the dialog's "Cancel"
163 button is pressed, or if :kbd:`Cmd-.` or :kbd:`ESC` is typed, the dialog window
164 is hidden and :exc:`KeyboardInterrupt` is raised (but note that this response
165 does not occur until the progress bar is next updated, typically via a call to
166 :meth:`inc` or :meth:`set`).  Otherwise, the bar remains visible until the
167 :class:`ProgressBar` object is discarded.
169 :class:`ProgressBar` objects possess the following attributes and methods:
172 .. attribute:: ProgressBar.curval
174    The current value (of type integer or long integer) of the progress bar.  The
175    normal access methods coerce :attr:`curval` between ``0`` and :attr:`maxval`.
176    This attribute should not be altered directly.
179 .. attribute:: ProgressBar.maxval
181    The maximum value (of type integer or long integer) of the progress bar; the
182    progress bar (thermometer style) is full when :attr:`curval` equals
183    :attr:`maxval`.  If :attr:`maxval` is ``0``, the bar will be indeterminate
184    (barber-pole).  This attribute should not be altered directly.
187 .. method:: ProgressBar.title([newstr])
189    Sets the text in the title bar of the progress dialog to *newstr*.
192 .. method:: ProgressBar.label([newstr])
194    Sets the text in the progress box of the progress dialog to *newstr*.
197 .. method:: ProgressBar.set(value[, max])
199    Sets the progress bar's :attr:`curval` to *value*, and also :attr:`maxval` to
200    *max* if the latter is provided.  *value* is first coerced between 0 and
201    :attr:`maxval`.  The thermometer bar is updated to reflect the changes,
202    including a change from indeterminate to determinate or vice versa.
205 .. method:: ProgressBar.inc([n])
207    Increments the progress bar's :attr:`curval` by *n*, or by ``1`` if *n* is not
208    provided.  (Note that *n* may be negative, in which case the effect is a
209    decrement.)  The progress bar is updated to reflect the change.  If the bar is
210    indeterminate, this causes one "spin" of the barber pole.  The resulting
211    :attr:`curval` is coerced between 0 and :attr:`maxval` if incrementing causes it
212    to fall outside this range.