Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions Doc/library/tkinter.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -4916,6 +4916,10 @@ Widget classes
``'always'``, ``'first'``, ``'last'``, ``'middle'`` or ``'never'``).
:meth:`paneconfig` is an alias of :meth:`!paneconfigure`.

.. deprecated-removed:: next 3.18
The first parameter was renamed from *tagOrId* to *child*.
The old name is still accepted as a keyword argument.

.. method:: identify(x, y)

Identify the panedwindow component underneath the point given by *x* and
Expand Down
21 changes: 21 additions & 0 deletions Lib/test/test_tkinter/test_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
22 changes: 18 additions & 4 deletions Lib/tkinter/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Loading