From f5fa057ca1d4ffc2981dabb1ebdb3048cd401293 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Sat, 27 Jun 2026 14:36:01 +0300 Subject: [PATCH 1/2] gh-50409: Modernize tkinter.PanedWindow.paneconfigure() Rename the first parameter of paneconfigure() (and its paneconfig alias) from 'tagOrId' to 'child', for consistency with add(), remove() and panecget() -- PanedWindow panes are child widgets, not tagged items. The old 'tagOrId' keyword still works but raises DeprecationWarning. Co-Authored-By: Claude Opus 4.8 --- Doc/library/tkinter.rst | 11 +++++++--- Lib/test/test_tkinter/test_widgets.py | 21 ++++++++++++++++++ Lib/tkinter/__init__.py | 22 +++++++++++++++---- ...6-06-27-11-32-37.gh-issue-50409.Pw3Kq9.rst | 4 ++++ 4 files changed, 51 insertions(+), 7 deletions(-) create mode 100644 Misc/NEWS.d/next/Library/2026-06-27-11-32-37.gh-issue-50409.Pw3Kq9.rst diff --git a/Doc/library/tkinter.rst b/Doc/library/tkinter.rst index c368141126403a..153b4a17eef23d 100644 --- a/Doc/library/tkinter.rst +++ b/Doc/library/tkinter.rst @@ -4895,13 +4895,13 @@ Widget classes containing *child*. *option* may be any value allowed by :meth:`paneconfigure`. - .. method:: paneconfig(tagOrId, cnf=None, **kw) + .. method:: paneconfig(child, cnf=None, **kw) :no-typesetting: - .. method:: paneconfigure(tagOrId, cnf=None, **kw) + .. method:: paneconfigure(child, cnf=None, **kw) Query or modify the management options of the pane containing the widget - *tagOrId*. + *child*. With no options, it returns a dictionary describing all of the available options for the pane; given a single option name as a string, it returns a description of that one option; otherwise it sets the given options. @@ -4916,6 +4916,11 @@ Widget classes ``'always'``, ``'first'``, ``'last'``, ``'middle'`` or ``'never'``). :meth:`paneconfig` is an alias of :meth:`!paneconfigure`. + .. versionchanged:: next + The first parameter was renamed from *tagOrId* to *child*. + The old name is still accepted as a keyword argument, + but it is deprecated and will be removed in Python 3.18. + .. method:: identify(x, y) Identify the panedwindow component underneath the point given by *x* and diff --git a/Lib/test/test_tkinter/test_widgets.py b/Lib/test/test_tkinter/test_widgets.py index 4b7a6acfad0b92..069f321a33b0c8 100644 --- a/Lib/test/test_tkinter/test_widgets.py +++ b/Lib/test/test_tkinter/test_widgets.py @@ -2391,6 +2391,27 @@ def test_paneconfigure_width(self): self.check_paneconfigure_bad(p, b, 'width', EXPECTED_SCREEN_DISTANCE_OR_EMPTY_ERRMSG.format('badValue')) + def test_paneconfigure_child(self): + p, b, c = self.create2() + # The child pane is the first argument, positionally or by keyword. + p.paneconfigure(b, minsize=40) + self.assertEqual(p.panecget(b, 'minsize'), 40) + p.paneconfigure(child=b, minsize=50) + self.assertEqual(p.panecget(b, 'minsize'), 50) + self.assertIsInstance(p.paneconfigure(b), dict) + self.assertEqual(p.paneconfigure(b, 'minsize')[4], 50) + # Omitting the child is an error. + self.assertRaises(TypeError, p.paneconfigure) + + def test_paneconfigure_tagOrId_deprecated(self): + p, b, c = self.create2() + # 'tagOrId' is a deprecated alias of 'child'. + with self.assertWarns(DeprecationWarning): + p.paneconfigure(tagOrId=b, minsize=40) + self.assertEqual(p.panecget(b, 'minsize'), 40) + # Giving both 'child' and 'tagOrId' is an error. + self.assertRaises(TypeError, p.paneconfigure, b, tagOrId=c) + @add_configure_tests(StandardOptionsTests) class MenuTest(AbstractWidgetTest, unittest.TestCase): diff --git a/Lib/tkinter/__init__.py b/Lib/tkinter/__init__.py index 897a1ba093c272..4b6b681234fff6 100644 --- a/Lib/tkinter/__init__.py +++ b/Lib/tkinter/__init__.py @@ -5293,7 +5293,7 @@ def panecget(self, child, option): return self.tk.call( (self._w, 'panecget') + (child, '-'+option)) - def paneconfigure(self, tagOrId, cnf=None, **kw): + def paneconfigure(self, child=None, cnf=None, **kw): """Query or modify the configuration options for a child window. Similar to configure() except that it applies to the specified @@ -5355,12 +5355,26 @@ def paneconfigure(self, tagOrId, cnf=None, **kw): Tk_GetPixels. """ + if 'tagOrId' in kw: + if child is not None: + raise TypeError("paneconfigure() got values for both 'child' " + "and its deprecated alias 'tagOrId'") + import warnings + warnings.warn( + "The 'tagOrId' parameter of PanedWindow.paneconfigure() " + "is deprecated and will be removed in Python 3.18; " + "use 'child' instead.", + DeprecationWarning, stacklevel=2) + child = kw.pop('tagOrId') + if child is None: + raise TypeError("paneconfigure() missing 1 required positional " + "argument: 'child'") if cnf is None and not kw: - return self._getconfigure(self._w, 'paneconfigure', tagOrId) + return self._getconfigure(self._w, 'paneconfigure', child) if isinstance(cnf, str) and not kw: return self._getconfigure1( - self._w, 'paneconfigure', tagOrId, '-'+cnf) - self.tk.call((self._w, 'paneconfigure', tagOrId) + + self._w, 'paneconfigure', child, '-'+cnf) + self.tk.call((self._w, 'paneconfigure', child) + self._options(cnf, kw)) paneconfig = paneconfigure diff --git a/Misc/NEWS.d/next/Library/2026-06-27-11-32-37.gh-issue-50409.Pw3Kq9.rst b/Misc/NEWS.d/next/Library/2026-06-27-11-32-37.gh-issue-50409.Pw3Kq9.rst new file mode 100644 index 00000000000000..479a2a3a8e1252 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-06-27-11-32-37.gh-issue-50409.Pw3Kq9.rst @@ -0,0 +1,4 @@ +Deprecate the *tagOrId* parameter of +:meth:`!tkinter.PanedWindow.paneconfigure` (and its :meth:`!paneconfig` +alias) in favor of *child*, for consistency with the other pane methods; +it will be removed in Python 3.18. From 2946dc68fb1683b7baf329d8a3d0ce9a0fabaece Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Sat, 11 Jul 2026 08:28:30 +0300 Subject: [PATCH 2/2] gh-50409: Use the deprecated-removed directive in the docs Co-Authored-By: Claude Opus 4.8 --- Doc/library/tkinter.rst | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Doc/library/tkinter.rst b/Doc/library/tkinter.rst index 153b4a17eef23d..2b38895db91449 100644 --- a/Doc/library/tkinter.rst +++ b/Doc/library/tkinter.rst @@ -4916,10 +4916,9 @@ Widget classes ``'always'``, ``'first'``, ``'last'``, ``'middle'`` or ``'never'``). :meth:`paneconfig` is an alias of :meth:`!paneconfigure`. - .. versionchanged:: next + .. deprecated-removed:: next 3.18 The first parameter was renamed from *tagOrId* to *child*. - The old name is still accepted as a keyword argument, - but it is deprecated and will be removed in Python 3.18. + The old name is still accepted as a keyword argument. .. method:: identify(x, y)