Skip to content

Commit 2027088

Browse files
[3.14] gh-86726: Document tkinter.simpledialog query options and Dialog.result (GH-151851) (GH-151853)
(cherry picked from commit 8270ae5) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
1 parent 8ef6016 commit 2027088

1 file changed

Lines changed: 22 additions & 6 deletions

File tree

Doc/library/dialog.rst

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,31 @@ The :mod:`!tkinter.simpledialog` module contains convenience classes and
1515
functions for creating simple modal dialogs to get a value from the user.
1616

1717

18-
.. function:: askfloat(title, prompt, **kw)
19-
askinteger(title, prompt, **kw)
20-
askstring(title, prompt, **kw)
18+
.. function:: askfloat(title, prompt, *, initialvalue=None, minvalue=None, maxvalue=None, parent=None)
19+
askinteger(title, prompt, *, initialvalue=None, minvalue=None, maxvalue=None, parent=None)
20+
askstring(title, prompt, *, initialvalue=None, show=None, parent=None)
2121
22-
The above three functions provide dialogs that prompt the user to enter a value
23-
of the desired type.
22+
Prompt the user to enter a value of the desired type and return it, or
23+
``None`` if the dialog is cancelled.
24+
25+
*title* is the dialog title and *prompt* the message shown above the entry.
26+
*initialvalue* is the value initially placed in the entry.
27+
*parent* is the window over which the dialog is shown.
28+
:func:`askinteger` and :func:`askfloat` also accept *minvalue* and
29+
*maxvalue*, which bound the accepted value.
30+
:func:`askstring` also accepts *show*, a character used to mask the entered
31+
text, for example ``'*'`` to hide a password.
2432

2533
.. class:: Dialog(parent, title=None)
2634

2735
The base class for custom dialogs.
36+
Instantiating it shows the dialog modally and returns once the user closes
37+
it; the entered value is then available in the :attr:`!result` attribute.
38+
39+
.. attribute:: result
40+
41+
The value produced by :meth:`apply`, or ``None`` if the dialog was
42+
cancelled.
2843

2944
.. method:: body(master)
3045

@@ -46,7 +61,8 @@ functions for creating simple modal dialogs to get a value from the user.
4661

4762
.. method:: apply()
4863

49-
Process the data entered by the user.
64+
Process the data entered by the user, for example by storing it in the
65+
:attr:`!result` attribute.
5066
Called after :meth:`validate` succeeds and just before the dialog is
5167
destroyed.
5268
The default implementation does nothing; override it to act on or store

0 commit comments

Comments
 (0)