@@ -15,16 +15,41 @@ The :mod:`!tkinter.simpledialog` module contains convenience classes and
1515functions 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, use_ttk=True )
19+ askinteger(title, prompt, *, initialvalue=None, minvalue=None, maxvalue=None, parent=None, use_ttk=True )
20+ askstring(title, prompt, *, initialvalue=None, show=None, parent=None, use_ttk=True )
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.
32+ They use the themed :mod: `tkinter.ttk ` widgets; pass ``use_ttk=False `` for
33+ the classic widgets.
2434
25- .. class :: Dialog(parent, title=None)
35+ .. class :: Dialog(parent, title=None, *, use_ttk=False )
2636
2737 The base class for custom dialogs.
38+ Instantiating it shows the dialog modally and returns once the user closes
39+ it; the entered value is then available in the :attr: `!result ` attribute.
40+ When *use_ttk * is false (the default), the dialog is built from the classic
41+ :mod: `tkinter ` widgets, modelled on the classic ``tk_dialog ``; when true,
42+ from the themed :mod: `tkinter.ttk ` widgets, modelled on the Tk message box.
43+ The default is classic for compatibility, since the themed widgets set a
44+ themed background that classic widgets added in :meth: `body ` would not match.
45+
46+ .. versionchanged :: next
47+ Added the *use_ttk * parameter.
48+
49+ .. attribute :: result
50+
51+ The value produced by :meth: `apply `, or ``None `` if the dialog was
52+ cancelled.
2853
2954 .. method :: body(master)
3055
@@ -46,7 +71,8 @@ functions for creating simple modal dialogs to get a value from the user.
4671
4772 .. method :: apply()
4873
49- Process the data entered by the user.
74+ Process the data entered by the user, for example by storing it in the
75+ :attr: `!result ` attribute.
5076 Called after :meth: `validate ` succeeds and just before the dialog is
5177 destroyed.
5278 The default implementation does nothing; override it to act on or store
@@ -58,14 +84,32 @@ functions for creating simple modal dialogs to get a value from the user.
5884 the initial focus.
5985
6086
61- .. class :: SimpleDialog(master, text='', buttons=[], default=None, cancel=None, title=None, class_=None)
87+ .. class :: SimpleDialog(master, text='', buttons=[], default=None, cancel=None, title=None, class_=None, *, bitmap=None, detail='', use_ttk=True )
6288
6389 A simple modal dialog that displays the message *text * above a row of push
64- buttons whose labels are given by *buttons *, and returns the index of the
65- button the user presses.
66- *default * is the index of the button activated by the Return key, *cancel *
67- the index returned when the window is closed through the window manager,
68- *title * the window title, and *class_ * the Tk class name of the window.
90+ buttons given by *buttons *, and returns the index of the button the user
91+ presses.
92+ Each entry of *buttons * is either a button label, or a mapping of button
93+ options such as ``{'text': 'OK', 'underline': 0} ``; an ``underline `` option
94+ makes :kbd: `Alt ` plus the underlined character invoke the button.
95+ *default * is the index of the default button, activated by the Return key
96+ when no button has the focus, *cancel * the index returned when the window is
97+ closed through the window manager, *title * the window title, and *class_ *
98+ the Tk class name of the window.
99+ *bitmap * is the name of a bitmap displayed beside the message
100+ (for example ``'warning' `` or ``'question' ``); the standard names
101+ ``'error' ``, ``'info' ``, ``'question' `` and ``'warning' `` are shown as
102+ themed icons when *use_ttk * is true.
103+ *detail * is a secondary message displayed below *text *.
104+ When *use_ttk * is true (the default), the dialog is built from the themed
105+ :mod: `tkinter.ttk ` widgets, modelled on the Tk message box; when false, from
106+ the classic :mod: `tkinter ` widgets, modelled on ``tk_dialog ``.
107+
108+ .. versionchanged :: next
109+ The dialog is now built from the themed :mod: `tkinter.ttk ` widgets by
110+ default, instead of the classic :mod: `tkinter ` widgets.
111+ Added the *bitmap *, *detail * and *use_ttk * parameters.
112+ Entries of *buttons * may be mappings of button options.
69113
70114 .. method :: go()
71115
0 commit comments