Skip to content

Commit a66bb06

Browse files
authored
Merge branch 'python:main' into main
2 parents 7739a8e + ad38cf8 commit a66bb06

27 files changed

Lines changed: 1316 additions & 208 deletions

.github/workflows/jit.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,10 @@ jobs:
6464
include:
6565
- target: i686-pc-windows-msvc/msvc
6666
architecture: Win32
67-
runner: windows-2025-vs2026
67+
runner: windows-2025
6868
- target: x86_64-pc-windows-msvc/msvc
6969
architecture: x64
70-
runner: windows-2025-vs2026
70+
runner: windows-2025
7171
- target: aarch64-pc-windows-msvc/msvc
7272
architecture: ARM64
7373
runner: windows-11-arm

.github/workflows/reusable-windows-msi.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ env:
1717
jobs:
1818
build:
1919
name: installer for ${{ inputs.arch }}
20-
runs-on: ${{ inputs.arch == 'arm64' && 'windows-11-arm' || 'windows-2025-vs2026' }}
20+
runs-on: ${{ inputs.arch == 'arm64' && 'windows-11-arm' || 'windows-2025' }}
2121
timeout-minutes: 60
2222
env:
2323
ARCH: ${{ inputs.arch }}

.github/workflows/reusable-windows.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ env:
2626
jobs:
2727
build:
2828
name: Build and test (${{ inputs.arch }}, ${{ inputs.interpreter }})
29-
runs-on: ${{ inputs.arch == 'arm64' && 'windows-11-arm' || 'windows-2025-vs2026' }}
29+
runs-on: ${{ inputs.arch == 'arm64' && 'windows-11-arm' || 'windows-2025' }}
3030
timeout-minutes: 60
3131
env:
3232
ARCH: ${{ inputs.arch }}

Doc/extending/extending.rst

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -231,10 +231,8 @@ calling the Python callback functions from a C callback. Other uses are also
231231
imaginable.
232232

233233
Fortunately, the Python interpreter is easily called recursively, and there is a
234-
standard interface to call a Python function. (I won't dwell on how to call the
235-
Python parser with a particular string as input --- if you're interested, have a
236-
look at the implementation of the :option:`-c` command line option in
237-
:file:`Modules/main.c` from the Python source code.)
234+
standard interface to call a Python function. (If you're interested in how to call the
235+
Python parser with a particular string as input, see :ref:`veryhigh`.)
238236

239237
Calling a Python function is easy. First, the Python program must somehow pass
240238
you the Python function object. You should provide a function (or some other
@@ -641,7 +639,7 @@ and the object is freed.
641639

642640
An alternative strategy is called :dfn:`automatic garbage collection`.
643641
(Sometimes, reference counting is also referred to as a garbage collection
644-
strategy, hence my use of "automatic" to distinguish the two.) The big
642+
strategy, hence the use of "automatic" to distinguish the two.) The big
645643
advantage of automatic garbage collection is that the user doesn't need to call
646644
:c:func:`free` explicitly. (Another claimed advantage is an improvement in speed
647645
or memory usage --- this is no hard fact however.) The disadvantage is that for

Doc/library/dialog.rst

Lines changed: 38 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ 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, *, 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)
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
2222
Prompt the user to enter a value of the desired type and return it, or
2323
``None`` if the dialog is cancelled.
@@ -29,12 +29,22 @@ functions for creating simple modal dialogs to get a value from the user.
2929
*maxvalue*, which bound the accepted value.
3030
:func:`askstring` also accepts *show*, a character used to mask the entered
3131
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.
3234

33-
.. class:: Dialog(parent, title=None)
35+
.. class:: Dialog(parent, title=None, *, use_ttk=False)
3436

3537
The base class for custom dialogs.
3638
Instantiating it shows the dialog modally and returns once the user closes
3739
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.
3848

3949
.. attribute:: result
4050

@@ -74,14 +84,32 @@ functions for creating simple modal dialogs to get a value from the user.
7484
the initial focus.
7585

7686

77-
.. 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)
7888

7989
A simple modal dialog that displays the message *text* above a row of push
80-
buttons whose labels are given by *buttons*, and returns the index of the
81-
button the user presses.
82-
*default* is the index of the button activated by the Return key, *cancel*
83-
the index returned when the window is closed through the window manager,
84-
*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.
85113

86114
.. method:: go()
87115

Doc/library/tkinter.rst

Lines changed: 73 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1955,6 +1955,37 @@ Base and mixin classes
19551955
color change when the mouse passes over a slider).
19561956
Return the resulting setting.
19571957

1958+
.. method:: tk_appname(name=None)
1959+
1960+
Query or set the name used to communicate with this application through
1961+
the ``send`` command.
1962+
With no argument, return the current name; otherwise change it to *name*
1963+
and return the actual name set, which may have a suffix appended to keep
1964+
it unique among the applications on the display.
1965+
1966+
.. versionadded:: next
1967+
1968+
.. method:: tk_useinputmethods(boolean=None, *, displayof=0)
1969+
1970+
Query or set whether Tk uses the X Input Methods (XIM) for filtering
1971+
events, and return the resulting state.
1972+
This is significant only on X11; if XIM support is not available it
1973+
always returns ``False``.
1974+
1975+
.. versionadded:: next
1976+
1977+
.. method:: tk_caret(*, x=None, y=None, height=None)
1978+
1979+
Set or query the caret location for the widget's display.
1980+
The caret is the per-display insertion position used for global focus
1981+
indication (for accessibility) and for placing the input method
1982+
(XIM or IME) window.
1983+
With no argument, return the current location as a dictionary with the
1984+
keys ``'x'``, ``'y'`` and ``'height'``; otherwise update the given
1985+
coordinates.
1986+
1987+
.. versionadded:: next
1988+
19581989
.. method:: tk_scaling(number=None, *, displayof=0)
19591990

19601991
Query or set the scaling factor used by Tk to convert between physical
@@ -4813,6 +4844,8 @@ Widget classes
48134844
is the initial choice, and *values* are the remaining menu entries.
48144845
The keyword argument *command* may be given a callback that is invoked with
48154846
the selected value, and the keyword argument *name* sets the Tk widget name.
4847+
Other keyword arguments are passed to the underlying :class:`Menubutton`
4848+
and may override its default appearance.
48164849

48174850
.. method:: destroy()
48184851

@@ -4821,6 +4854,9 @@ Widget classes
48214854
.. versionchanged:: 3.14
48224855
Added support for the *name* keyword argument.
48234856

4857+
.. versionchanged:: next
4858+
Other :class:`Menubutton` options can now be passed as keyword arguments.
4859+
48244860

48254861

48264862
.. class:: PanedWindow(master=None, cnf={}, **kw)
@@ -6151,7 +6187,7 @@ Image classes
61516187

61526188

61536189
.. method:: data(format=None, *, from_coords=None, background=None, \
6154-
grayscale=False)
6190+
grayscale=False, metadata=None)
61556191

61566192
Return the image data.
61576193

@@ -6175,16 +6211,27 @@ Image classes
61756211
If *grayscale* is true, the data does not contain color information; all
61766212
pixel data is transformed into grayscale.
61776213

6214+
*metadata* is a dictionary passed to the image format driver.
6215+
It requires Tcl/Tk 9.0 or newer.
6216+
61786217
.. versionadded:: 3.13
61796218

6219+
.. versionchanged:: next
6220+
Added the *metadata* parameter.
61806221

6181-
.. method:: get(x, y)
6222+
6223+
.. method:: get(x, y, *, withalpha=False)
61826224

61836225
Return the color of the pixel at coordinates (*x*, *y*) as an
61846226
``(r, g, b)`` tuple of three integers between 0 and 255, representing the
61856227
red, green and blue components respectively.
6228+
If *withalpha* is true, the returned tuple has a fourth element giving
6229+
the alpha (opacity) value of the pixel.
6230+
6231+
.. versionchanged:: next
6232+
Added the *withalpha* parameter, which requires Tcl/Tk 9.0 or newer.
61866233

6187-
.. method:: put(data, to=None)
6234+
.. method:: put(data, to=None, *, format=None, metadata=None)
61886235

61896236
Set pixels of the image to the colors given in *data*, which must be a
61906237
string or a nested sequence of horizontal rows of pixel colors (for
@@ -6197,13 +6244,25 @@ Image classes
61976244
bottom-right corner, of the region.
61986245
The default position is ``(0, 0)``.
61996246

6247+
*format* specifies the format of the image *data*, so that only image
6248+
file format handlers whose names begin with it are tried.
6249+
6250+
*metadata* is a dictionary passed to the image format driver.
6251+
It requires Tcl/Tk 9.0 or newer.
6252+
6253+
.. versionchanged:: next
6254+
Added the *format* and *metadata* parameters.
6255+
62006256
.. method:: read(filename, format=None, *, from_coords=None, to=None, \
6201-
shrink=False)
6257+
shrink=False, metadata=None)
62026258

62036259
Read image data from the file named *filename* into the image.
62046260

62056261
*format* specifies the format of the image data in the file.
62066262

6263+
*metadata* is a dictionary passed to the image format driver.
6264+
It requires Tcl/Tk 9.0 or newer.
6265+
62076266
*from_coords* specifies a rectangular sub-region of the image file data
62086267
to be copied to the destination image.
62096268
It must be a tuple or a list of 1 to 4 integers ``(x1, y1, x2, y2)``.
@@ -6224,6 +6283,9 @@ Image classes
62246283

62256284
.. versionadded:: 3.13
62266285

6286+
.. versionchanged:: next
6287+
Added the *metadata* parameter.
6288+
62276289

62286290
.. method:: subsample(x, y='', *, from_coords=None)
62296291

@@ -6256,7 +6318,7 @@ Image classes
62566318

62576319

62586320
.. method:: write(filename, format=None, from_coords=None, *, \
6259-
background=None, grayscale=False)
6321+
background=None, grayscale=False, metadata=None)
62606322

62616323
Write image data from the image to the file named *filename*.
62626324

@@ -6278,9 +6340,15 @@ Image classes
62786340
If *grayscale* is true, the data does not contain color information; all
62796341
pixel data is transformed into grayscale.
62806342

6343+
*metadata* is a dictionary passed to the image format driver.
6344+
It requires Tcl/Tk 9.0 or newer.
6345+
62816346
.. versionchanged:: 3.13
62826347
Added the *background* and *grayscale* parameters.
62836348

6349+
.. versionchanged:: next
6350+
Added the *metadata* parameter.
6351+
62846352

62856353
.. method:: zoom(x, y='', *, from_coords=None)
62866354

Doc/library/tkinter.ttk.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2016,6 +2016,16 @@ If you don't know the class name of a widget, use the method
20162016
Returns a tuple of all known themes.
20172017

20182018

2019+
.. method:: theme_styles(themename=None)
2020+
2021+
Returns a tuple of all styles in *themename*.
2022+
If *themename* is not given, the current theme is used.
2023+
2024+
.. versionadded:: next
2025+
2026+
Availability: Tk 9.0.
2027+
2028+
20192029
.. method:: theme_use(themename=None)
20202030

20212031
If *themename* is not given, returns the theme in use. Otherwise, sets

Doc/whatsnew/3.16.rst

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,11 @@ tkinter
173173
synchronization of the displayed view with the underlying text.
174174
(Contributed by Serhiy Storchaka in :gh:`151675`.)
175175

176+
* Added the :meth:`ttk.Style.theme_styles
177+
<tkinter.ttk.Style.theme_styles>` method which returns the list of styles
178+
defined in a theme.
179+
(Contributed by Serhiy Storchaka in :gh:`151920`.)
180+
176181
* Added new :class:`!tkinter.Canvas` methods :meth:`~tkinter.Canvas.rchars`
177182
which replaces the text or coordinates of canvas items, and
178183
:meth:`~tkinter.Canvas.rotate` which rotates the coordinates of canvas items.
@@ -194,10 +199,42 @@ tkinter
194199
badge) and :meth:`~tkinter.Wm.wm_stackorder` (toplevel stacking order).
195200
(Contributed by Serhiy Storchaka in :gh:`151874`.)
196201

202+
* Added the :meth:`~tkinter.Misc.tk_appname`,
203+
:meth:`~tkinter.Misc.tk_useinputmethods` and :meth:`~tkinter.Misc.tk_caret`
204+
methods, exposing the application send name, the X Input Methods state and
205+
the input method caret location.
206+
(Contributed by Serhiy Storchaka in :gh:`151886`.)
207+
208+
* Added support for more options in :class:`!tkinter.PhotoImage` methods: the
209+
*format* parameter of :meth:`~tkinter.PhotoImage.put`, the *metadata*
210+
parameter of :meth:`~tkinter.PhotoImage.put`, :meth:`~tkinter.PhotoImage.read`,
211+
:meth:`~tkinter.PhotoImage.write` and :meth:`~tkinter.PhotoImage.data`, and
212+
the *withalpha* parameter of :meth:`~tkinter.PhotoImage.get`.
213+
(Contributed by Serhiy Storchaka in :gh:`151890`.)
214+
197215
* Added the :meth:`~tkinter.PhotoImage.redither` method which recalculates the
198216
dithered image when its data was supplied in pieces.
199217
(Contributed by Serhiy Storchaka in :gh:`151888`.)
200218

219+
* :class:`tkinter.OptionMenu` now accepts arbitrary :class:`!tkinter.Menubutton`
220+
options as keyword arguments, which can also override its default appearance.
221+
(Contributed by Serhiy Storchaka in :gh:`101284`.)
222+
223+
* The :mod:`tkinter.simpledialog` dialogs were modernized to match the look
224+
and feel of the native Tk dialogs.
225+
:class:`!tkinter.simpledialog.SimpleDialog` and the
226+
:func:`~tkinter.simpledialog.askinteger`,
227+
:func:`~tkinter.simpledialog.askfloat` and
228+
:func:`~tkinter.simpledialog.askstring` dialogs are now built from the themed
229+
:mod:`tkinter.ttk` widgets instead of the classic :mod:`tkinter` widgets;
230+
the :class:`!tkinter.simpledialog.Dialog` base class still defaults to the
231+
classic widgets for compatibility. Both :class:`!Dialog` and
232+
:class:`!SimpleDialog` gained a *use_ttk* parameter that selects between the
233+
classic Tk widgets and the themed ttk widgets. :class:`!SimpleDialog` also
234+
gained *bitmap* and
235+
*detail* parameters, draws the standard icons with themed images in the
236+
ttk version, and accepts mappings of button options as *buttons* entries.
237+
(Contributed by Serhiy Storchaka in :gh:`59396`.)
201238

202239
xml
203240
---

Lib/idlelib/idle_test/test_iomenu.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,10 @@ def setUpClass(cls):
2323
cls.root = Tk()
2424
cls.root.withdraw()
2525
cls.editwin = EditorWindow(root=cls.root)
26-
cls.io = iomenu.IOBinding(cls.editwin)
26+
cls.io = cls.editwin.io
2727

2828
@classmethod
2929
def tearDownClass(cls):
30-
cls.io.close()
3130
cls.editwin._close()
3231
del cls.editwin
3332
cls.root.update_idletasks()

0 commit comments

Comments
 (0)