Skip to content

Commit d714d68

Browse files
Merge branch 'main' into gh-130110-email-hyphen-param
2 parents 5fa95ba + 0023d5b commit d714d68

58 files changed

Lines changed: 2237 additions & 1049 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Doc/deprecations/pending-removal-in-3.19.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,11 @@ Pending removal in Python 3.19
4040
Before Python 3.14, this property was used to implement the corresponding
4141
``read()`` and ``readline()`` methods for :class:`~imaplib.IMAP4` but this
4242
is no longer the case since then.
43+
44+
* :mod:`tkinter`:
45+
46+
* :func:`tkinter.filedialog.askopenfiles` has been deprecated since Python
47+
3.16. Iterate over the names returned by
48+
:func:`~tkinter.filedialog.askopenfilenames` and open them one by one
49+
instead.
50+
(Contributed by Serhiy Storchaka in :gh:`152638`.)

Doc/library/asyncio-queue.rst

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ Queue
7171
Return an item if one is immediately available, else raise
7272
:exc:`QueueEmpty`.
7373

74+
Raises :exc:`QueueShutDown` if the queue has been shut down and is empty.
75+
7476
.. method:: join()
7577
:async:
7678

@@ -96,6 +98,8 @@ Queue
9698

9799
If no free slot is immediately available, raise :exc:`QueueFull`.
98100

101+
Raises :exc:`QueueShutDown` if the queue has been shut down.
102+
99103
.. method:: qsize()
100104

101105
Return the number of items in the queue.
@@ -188,8 +192,9 @@ Exceptions
188192

189193
.. exception:: QueueShutDown
190194

191-
Exception raised when :meth:`~Queue.put` or :meth:`~Queue.get` is
192-
called on a queue which has been shut down.
195+
Exception raised when :meth:`~Queue.put`, :meth:`~Queue.put_nowait`,
196+
:meth:`~Queue.get` or :meth:`~Queue.get_nowait` is called
197+
on a queue which has been shut down.
193198

194199
.. versionadded:: 3.13
195200

Doc/library/dialog.rst

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -163,15 +163,23 @@ cancelled it is the empty value documented for that function -- an empty
163163
string, an empty tuple, an empty list or ``None``.
164164

165165
.. function:: askopenfile(mode="r", **options)
166-
askopenfiles(mode="r", **options)
167166

168-
Create an :class:`Open` dialog.
169-
:func:`askopenfile` returns the opened file object, or ``None`` if the
170-
dialog is cancelled.
171-
:func:`askopenfiles` returns a list of the opened file objects, or an empty
172-
list if cancelled.
167+
Create an :class:`Open` dialog and return the opened file object,
168+
or ``None`` if the dialog is cancelled.
169+
The file is opened in mode *mode* (read-only ``'r'`` by default).
170+
171+
.. function:: askopenfiles(mode="r", **options)
172+
173+
Create an :class:`Open` dialog and return a list of the opened file objects,
174+
or an empty list if cancelled.
173175
The files are opened in mode *mode* (read-only ``'r'`` by default).
174176

177+
.. deprecated-removed:: next 3.19
178+
Opening several files at once is error-prone,
179+
and the returned list cannot be used in a :keyword:`with` statement.
180+
Iterate over the names returned by :func:`askopenfilenames`
181+
and open them one by one instead.
182+
175183
.. function:: asksaveasfile(mode="w", **options)
176184

177185
Create a :class:`SaveAs` dialog and return the opened file object, or
@@ -201,19 +209,16 @@ string, an empty tuple, an empty list or ``None``.
201209

202210
.. class:: Open(master=None, **options)
203211
SaveAs(master=None, **options)
212+
Directory(master=None, **options)
204213
205-
The above two classes provide native dialog windows for saving and loading
206-
files.
214+
The above three classes provide native dialog windows for loading and saving
215+
files and for selecting a directory.
207216

208217
**Convenience classes**
209218

210219
The below classes are used for creating file/directory windows from scratch.
211220
These do not emulate the native look-and-feel of the platform.
212221

213-
.. class:: Directory(master=None, **options)
214-
215-
Create a dialog prompting the user to select a directory.
216-
217222
.. note:: The *FileDialog* class should be subclassed for custom event
218223
handling and behaviour.
219224

@@ -353,23 +358,25 @@ the classic (non-themed) Tk widgets.
353358

354359
.. data:: DIALOG_ICON
355360

356-
The name of the default bitmap (``'questhead'``) displayed by a
357-
:class:`Dialog`.
361+
The name of a bitmap (``'questhead'``) suitable for use as the *bitmap*
362+
of a :class:`Dialog`.
358363

359364
.. class:: Dialog(master=None, cnf={}, **kw)
360365

361366
Display a modal dialog box built from the classic (non-themed) Tk widgets
362367
and wait for the user to press one of its buttons.
363-
The options, given through *cnf* or as keyword arguments, include *title*
364-
(the window title), *text* (the message), *bitmap* (an icon,
365-
:data:`DIALOG_ICON` by default), *default* (the index of the default button)
366-
and *strings* (the sequence of button labels).
368+
The options, given through *cnf* or as keyword arguments, are all required:
369+
*title* (the window title), *text* (the message), *bitmap* (the name of a
370+
bitmap icon, such as :data:`DIALOG_ICON`), *default* (the index of the
371+
default button) and *strings* (the sequence of button labels).
367372
After construction, the :attr:`!num` attribute holds the index of the button
368373
the user pressed.
369374

370375
.. method:: destroy()
371376

372-
Destroy the dialog window.
377+
Do nothing.
378+
The dialog window is destroyed automatically before the constructor
379+
returns, so there is nothing left for this method to do.
373380

374381

375382
.. seealso::

Doc/library/tk.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,11 @@ alternative `GUI frameworks and tools <https://wiki.python.org/moin/GuiProgrammi
3333
tkinter.rst
3434
tkinter.colorchooser.rst
3535
tkinter.font.rst
36+
tkinter.fontchooser.rst
3637
dialog.rst
3738
tkinter.messagebox.rst
3839
tkinter.scrolledtext.rst
40+
tkinter.systray.rst
3941
tkinter.dnd.rst
4042
tkinter.ttk.rst
4143
idle.rst
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
:mod:`!tkinter.fontchooser` --- Font selection dialog
2+
=====================================================
3+
4+
.. module:: tkinter.fontchooser
5+
:synopsis: Font selection dialog
6+
7+
.. versionadded:: next
8+
9+
**Source code:** :source:`Lib/tkinter/fontchooser.py`
10+
11+
--------------
12+
13+
The :mod:`!tkinter.fontchooser` module provides the :class:`FontChooser` class
14+
as an interface to the native font selection dialog.
15+
16+
The font dialog is application-global:
17+
there is a single font dialog per Tcl interpreter,
18+
and all :class:`FontChooser` instances configure the same dialog.
19+
20+
Depending on the platform, the dialog may be modal or modeless,
21+
so :meth:`~FontChooser.show` may return immediately.
22+
The selected font is not returned:
23+
it is passed as a :class:`~tkinter.font.Font` object to the callback
24+
specified with the *command* option.
25+
26+
The dialog also generates two virtual events on the parent window
27+
(see the *parent* option):
28+
29+
``<<TkFontchooserVisibility>>``
30+
Generated when the dialog is shown or hidden.
31+
Query the *visible* option to tell which.
32+
33+
``<<TkFontchooserFontChanged>>``
34+
Generated when the selected font changes.
35+
36+
.. note::
37+
38+
The *command* callback is the only reliable way to obtain the selected font.
39+
On some platforms the *font* option is not updated to the user's choice.
40+
41+
.. class:: FontChooser(master=None, **options)
42+
43+
The class implementing the font selection dialog.
44+
45+
*master* is the widget whose Tcl interpreter owns the dialog.
46+
If omitted, it defaults to *parent* if that is given,
47+
or to the default root window otherwise.
48+
49+
The supported configuration options are:
50+
51+
* *parent* --- the window to which the dialog and its virtual events are related.
52+
It defaults to the main window;
53+
on macOS the dialog is shown as a sheet attached to it,
54+
rather than as a free-standing panel.
55+
* *title* --- the title of the dialog.
56+
* *font* --- the font that is currently selected in the dialog.
57+
* *command* --- a callback that is called
58+
with a :class:`~tkinter.font.Font` object wrapping the selected font
59+
when the user selects a font.
60+
* *visible* --- whether the dialog is currently displayed (read-only).
61+
62+
The *font* option accepts the forms supported by :class:`tkinter.font.Font`.
63+
64+
.. method:: configure(**options)
65+
config(**options)
66+
67+
Query or modify the options of the font dialog.
68+
With no arguments, return a dict of all option values.
69+
With a string argument, return the value of that option.
70+
Otherwise, set the given options.
71+
72+
.. method:: cget(option)
73+
74+
Return the value of the given option of the font dialog.
75+
76+
.. method:: show()
77+
78+
Display the font dialog.
79+
Depending on the platform, this method may return immediately
80+
or only once the dialog has been withdrawn.
81+
82+
.. method:: hide()
83+
84+
Hide the font dialog if it is displayed.
85+
86+
87+
.. seealso::
88+
89+
Module :mod:`tkinter.font`
90+
Tkinter font-handling utilities

Doc/library/tkinter.messagebox.rst

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@ a variety of convenience methods for commonly used configurations.
1313
The message boxes are modal: each blocks until the user responds, then returns
1414
a value that depends on the function.
1515
The ``show*`` functions and :meth:`Message.show` return the symbolic name of
16-
the button the user pressed, as a string (such as :data:`OK` or :data:`YES`),
17-
while the ``ask*`` functions return a :class:`bool` or ``None`` (see each
18-
function below).
16+
the button the user pressed, as a string (such as :data:`OK` or :data:`YES`).
1917
Common message box styles and layouts include but are not limited to:
2018

2119
.. figure:: tk_msg.png

Doc/library/tkinter.rst

Lines changed: 37 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,9 @@ The modules that provide Tk support include:
146146
:mod:`tkinter.font`
147147
Utilities to help work with fonts.
148148

149+
:mod:`tkinter.fontchooser`
150+
Dialog to let the user choose a font.
151+
149152
:mod:`tkinter.messagebox`
150153
Access to standard Tk dialog boxes.
151154

@@ -155,6 +158,9 @@ The modules that provide Tk support include:
155158
:mod:`tkinter.simpledialog`
156159
Basic dialogs and convenience functions.
157160

161+
:mod:`tkinter.systray`
162+
System tray icon and desktop notifications.
163+
158164
:mod:`tkinter.ttk`
159165
Themed widget set introduced in Tk 8.5, providing modern alternatives
160166
for many of the classic widgets in the main :mod:`!tkinter` module.
@@ -539,11 +545,8 @@ arguments, or by calling the :meth:`~Misc.keys` method on that widget.
539545
The return value of these calls is a dictionary whose key is the name of the
540546
option as a string (for example, ``'relief'``) and whose values are 5-tuples.
541547

542-
Some options, like ``bg`` are synonyms for common options with long names
543-
(``bg`` is shorthand for "background"). Passing the ``config()`` method the name
544-
of a shorthand option will return a 2-tuple, not 5-tuple. The 2-tuple passed
545-
back will contain the name of the synonym and the "real" option (such as
546-
``('bg', 'background')``).
548+
Some options, like ``bg``, are synonyms for common options with long names
549+
(``bg`` is shorthand for "background").
547550

548551
+-------+---------------------------------+--------------+
549552
| Index | Meaning | Example |
@@ -2353,8 +2356,8 @@ Base and mixin classes
23532356
If all four arguments are given, the window manager keeps the ratio
23542357
between ``minNumer/minDenom`` and ``maxNumer/maxDenom``; passing empty
23552358
strings removes any existing restriction.
2356-
With no arguments, return a tuple of the four current values, or an empty
2357-
string if no aspect restriction is in effect.
2359+
With no arguments, return a tuple of the four current values, or ``None``
2360+
if no aspect restriction is in effect.
23582361
:meth:`wm_aspect` is an alias of :meth:`!aspect`.
23592362

23602363
.. method:: wm_attributes(*args, return_python_dict=False, **kwargs)
@@ -2579,8 +2582,8 @@ Base and mixin classes
25792582
window's internally requested size, and *widthInc* and *heightInc* are
25802583
the pixel sizes of a horizontal and vertical grid unit.
25812584
Empty strings turn off gridded management.
2582-
With no arguments, return a tuple of the four current values, or an empty
2583-
string if the window is not gridded.
2585+
With no arguments, return a tuple of the four current values, or ``None``
2586+
if the window is not gridded.
25842587
:meth:`wm_grid` is an alias of :meth:`!grid`.
25852588

25862589
Not to be confused with the grid geometry manager :meth:`Grid.grid`.
@@ -2693,8 +2696,8 @@ Base and mixin classes
26932696
Set or query a hint to the window manager about where the window's icon
26942697
should be positioned.
26952698
Empty strings cancel an existing hint.
2696-
With no arguments, return a tuple of the two current values, or an empty
2697-
string if no hint is in effect.
2699+
With no arguments, return a tuple of the two current values, or ``None``
2700+
if no hint is in effect.
26982701
:meth:`wm_iconposition` is an alias of :meth:`!iconposition`.
26992702

27002703
.. method:: wm_iconwindow(pathName=None)
@@ -2763,7 +2766,8 @@ Base and mixin classes
27632766
When this flag is set, the window is ignored by the window manager: it is
27642767
not reparented into a decorative frame and the user cannot manipulate it
27652768
through the usual window manager controls.
2766-
With no argument, return a boolean indicating whether the flag is set.
2769+
With no argument, return a boolean indicating whether the flag is set,
2770+
or ``None`` if it has not been set.
27672771
The flag is reliably honored only when the window is first mapped or
27682772
remapped from the withdrawn state.
27692773
:meth:`wm_overrideredirect` is an alias of :meth:`!overrideredirect`.
@@ -3555,6 +3559,13 @@ Widget classes
35553559
A newly created item is placed at the top of the list; the order can be
35563560
changed with :meth:`tag_raise` and :meth:`tag_lower`.
35573561

3562+
.. method:: tk_print()
3563+
3564+
Print the contents of the canvas using the native print dialog.
3565+
Requires Tk 8.7/9.0 or newer.
3566+
3567+
.. versionadded:: next
3568+
35583569
.. method:: create_arc(*args, **kw)
35593570
create_bitmap(*args, **kw)
35603571
create_image(*args, **kw)
@@ -4925,13 +4936,13 @@ Widget classes
49254936
containing *child*.
49264937
*option* may be any value allowed by :meth:`paneconfigure`.
49274938

4928-
.. method:: paneconfig(tagOrId, cnf=None, **kw)
4939+
.. method:: paneconfig(child, cnf=None, **kw)
49294940
:no-typesetting:
49304941

4931-
.. method:: paneconfigure(tagOrId, cnf=None, **kw)
4942+
.. method:: paneconfigure(child, cnf=None, **kw)
49324943

49334944
Query or modify the management options of the pane containing the widget
4934-
*tagOrId*.
4945+
*child*.
49354946
With no options, it returns a dictionary describing all of the available
49364947
options for the pane; given a single option name as a string, it returns
49374948
a description of that one option; otherwise it sets the given options.
@@ -4946,6 +4957,10 @@ Widget classes
49464957
``'always'``, ``'first'``, ``'last'``, ``'middle'`` or ``'never'``).
49474958
:meth:`paneconfig` is an alias of :meth:`!paneconfigure`.
49484959

4960+
.. deprecated-removed:: next 3.18
4961+
The first parameter was renamed from *tagOrId* to *child*.
4962+
The old name is still accepted as a keyword argument.
4963+
49494964
.. method:: identify(x, y)
49504965

49514966
Identify the panedwindow component underneath the point given by *x* and
@@ -5366,6 +5381,13 @@ Widget classes
53665381
to its base; several modifiers may be combined and are applied from left to
53675382
right, for example ``'insert wordstart - 1 c'``.
53685383

5384+
.. method:: tk_print()
5385+
5386+
Print the contents of the text widget using the native print dialog.
5387+
Requires Tk 8.7/9.0 or newer.
5388+
5389+
.. versionadded:: next
5390+
53695391
.. method:: insert(index, chars, *args)
53705392

53715393
Insert the string *chars* just before the character at *index* (if

0 commit comments

Comments
 (0)