Skip to content

Commit 5573df1

Browse files
[3.14] gh-143754: Modernize Tkinter docs (GH-143841) (GH-144032)
Use more relevant terminology instead of "master"/"slave" widgets where possible. (cherry picked from commit 813fc7a) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
1 parent ea18782 commit 5573df1

File tree

2 files changed

+58
-47
lines changed

2 files changed

+58
-47
lines changed

Doc/library/tkinter.rst

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -177,12 +177,12 @@ the modern themed widget set and API::
177177
.. attribute:: master
178178

179179
The widget object that contains this widget. For :class:`Tk`, the
180-
*master* is :const:`None` because it is the main window. The terms
180+
:attr:`!master` is :const:`None` because it is the main window. The terms
181181
*master* and *parent* are similar and sometimes used interchangeably
182182
as argument names; however, calling :meth:`winfo_parent` returns a
183-
string of the widget name whereas :attr:`master` returns the object.
183+
string of the widget name whereas :attr:`!master` returns the object.
184184
*parent*/*child* reflects the tree-like relationship while
185-
*master*/*slave* reflects the container structure.
185+
*master* (or *container*)/*content* reflects the container structure.
186186

187187
.. attribute:: children
188188

@@ -638,15 +638,15 @@ The Packer
638638
.. index:: single: packing (widgets)
639639

640640
The packer is one of Tk's geometry-management mechanisms. Geometry managers
641-
are used to specify the relative positioning of widgets within their container -
642-
their mutual *master*. In contrast to the more cumbersome *placer* (which is
641+
are used to specify the relative positioning of widgets within their container.
642+
In contrast to the more cumbersome *placer* (which is
643643
used less commonly, and we do not cover here), the packer takes qualitative
644644
relationship specification - *above*, *to the left of*, *filling*, etc - and
645645
works everything out to determine the exact placement coordinates for you.
646646

647-
The size of any *master* widget is determined by the size of the "slave widgets"
648-
inside. The packer is used to control where slave widgets appear inside the
649-
master into which they are packed. You can pack widgets into frames, and frames
647+
The size of any container widget is determined by the size of the "content widgets"
648+
inside. The packer is used to control where content widgets appear inside the
649+
container into which they are packed. You can pack widgets into frames, and frames
650650
into other frames, in order to achieve the kind of layout you desire.
651651
Additionally, the arrangement is dynamically adjusted to accommodate incremental
652652
changes to the configuration, once it is packed.
@@ -673,7 +673,7 @@ For more extensive information on the packer and the options that it can take,
673673
see the man pages and page 183 of John Ousterhout's book.
674674

675675
anchor
676-
Anchor type. Denotes where the packer is to place each slave in its parcel.
676+
Anchor type. Denotes where the packer is to place each content in its parcel.
677677

678678
expand
679679
Boolean, ``0`` or ``1``.
@@ -682,10 +682,10 @@ fill
682682
Legal values: ``'x'``, ``'y'``, ``'both'``, ``'none'``.
683683

684684
ipadx and ipady
685-
A distance - designating internal padding on each side of the slave widget.
685+
A distance - designating internal padding on each side of the content.
686686

687687
padx and pady
688-
A distance - designating external padding on each side of the slave widget.
688+
A distance - designating external padding on each side of the content.
689689

690690
side
691691
Legal values are: ``'left'``, ``'right'``, ``'top'``, ``'bottom'``.
@@ -758,8 +758,8 @@ subclassed from the :class:`Wm` class, and so can call the :class:`Wm` methods
758758
directly.
759759

760760
To get at the toplevel window that contains a given widget, you can often just
761-
refer to the widget's master. Of course if the widget has been packed inside of
762-
a frame, the master won't represent a toplevel window. To get at the toplevel
761+
refer to the widget's :attr:`master`. Of course if the widget has been packed inside of
762+
a frame, the :attr:`!master` won't represent a toplevel window. To get at the toplevel
763763
window that contains an arbitrary widget, you can call the :meth:`_root` method.
764764
This method begins with an underscore to denote the fact that this function is
765765
part of the implementation, and not an interface to Tk functionality.

Lib/tkinter/__init__.py

Lines changed: 45 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1866,15 +1866,15 @@ def __repr__(self):
18661866
return '<%s.%s object %s>' % (
18671867
self.__class__.__module__, self.__class__.__qualname__, self._w)
18681868

1869-
# Pack methods that apply to the master
1869+
# Pack methods that apply to the container widget
18701870
_noarg_ = ['_noarg_']
18711871

18721872
def pack_propagate(self, flag=_noarg_):
18731873
"""Set or get the status for propagation of geometry information.
18741874
1875-
A boolean argument specifies whether the geometry information
1876-
of the slaves will determine the size of this widget. If no argument
1877-
is given the current setting will be returned.
1875+
A boolean argument specifies whether the size of this container will
1876+
be determined by the geometry information of its content.
1877+
If no argument is given the current setting will be returned.
18781878
"""
18791879
if flag is Misc._noarg_:
18801880
return self._getboolean(self.tk.call(
@@ -1885,28 +1885,28 @@ def pack_propagate(self, flag=_noarg_):
18851885
propagate = pack_propagate
18861886

18871887
def pack_slaves(self):
1888-
"""Return a list of all slaves of this widget
1889-
in its packing order."""
1888+
"""Returns a list of all of the content widgets in the packing order
1889+
for this container."""
18901890
return [self._nametowidget(x) for x in
18911891
self.tk.splitlist(
18921892
self.tk.call('pack', 'slaves', self._w))]
18931893

18941894
slaves = pack_slaves
18951895

1896-
# Place method that applies to the master
1896+
# Place method that applies to the container widget
18971897
def place_slaves(self):
1898-
"""Return a list of all slaves of this widget
1899-
in its packing order."""
1898+
"""Returns a list of all the content widgets for which this widget is
1899+
the container."""
19001900
return [self._nametowidget(x) for x in
19011901
self.tk.splitlist(
19021902
self.tk.call(
19031903
'place', 'slaves', self._w))]
19041904

1905-
# Grid methods that apply to the master
1905+
# Grid methods that apply to the container widget
19061906

19071907
def grid_anchor(self, anchor=None): # new in Tk 8.5
19081908
"""The anchor value controls how to place the grid within the
1909-
master when no row/column has any weight.
1909+
container widget when no row/column has any weight.
19101910
19111911
The default anchor is nw."""
19121912
self.tk.call('grid', 'anchor', self._w, anchor)
@@ -1923,7 +1923,7 @@ def grid_bbox(self, column=None, row=None, col2=None, row2=None):
19231923
starts at that cell.
19241924
19251925
The returned integers specify the offset of the upper left
1926-
corner in the master widget and the width and height.
1926+
corner in the container widget and the width and height.
19271927
"""
19281928
args = ('grid', 'bbox', self._w)
19291929
if column is not None and row is not None:
@@ -1981,7 +1981,7 @@ def grid_columnconfigure(self, index, cnf={}, **kw):
19811981

19821982
def grid_location(self, x, y):
19831983
"""Return a tuple of column and row which identify the cell
1984-
at which the pixel at position X and Y inside the master
1984+
at which the pixel at position X and Y inside the container
19851985
widget is located."""
19861986
return self._getints(
19871987
self.tk.call(
@@ -1990,9 +1990,9 @@ def grid_location(self, x, y):
19901990
def grid_propagate(self, flag=_noarg_):
19911991
"""Set or get the status for propagation of geometry information.
19921992
1993-
A boolean argument specifies whether the geometry information
1994-
of the slaves will determine the size of this widget. If no argument
1995-
is given, the current setting will be returned.
1993+
A boolean argument specifies whether the size of this container will
1994+
be determined by the geometry information of its content.
1995+
If no argument is given the current setting will be returned.
19961996
"""
19971997
if flag is Misc._noarg_:
19981998
return self._getboolean(self.tk.call(
@@ -2018,8 +2018,13 @@ def grid_size(self):
20182018
size = grid_size
20192019

20202020
def grid_slaves(self, row=None, column=None):
2021-
"""Return a list of all slaves of this widget
2022-
in its packing order."""
2021+
"""Returns a list of the content widgets.
2022+
2023+
If no arguments are supplied, a list of all of the content in this
2024+
container widget is returned, most recently managed first.
2025+
If ROW or COLUMN is specified, only the content in the row or
2026+
column is returned.
2027+
"""
20232028
args = ()
20242029
if row is not None:
20252030
args = args + ('-row', row)
@@ -2605,8 +2610,8 @@ def pack_configure(self, cnf={}, **kw):
26052610
before=widget - pack it before you will pack widget
26062611
expand=bool - expand widget if parent size grows
26072612
fill=NONE or X or Y or BOTH - fill widget if widget grows
2608-
in=master - use master to contain this widget
2609-
in_=master - see 'in' option description
2613+
in=container - use the container widget to contain this widget
2614+
in_=container - see 'in' option description
26102615
ipadx=amount - add internal padding in x direction
26112616
ipady=amount - add internal padding in y direction
26122617
padx=amount - add padding in x direction
@@ -2645,25 +2650,31 @@ class Place:
26452650

26462651
def place_configure(self, cnf={}, **kw):
26472652
"""Place a widget in the parent widget. Use as options:
2648-
in=master - master relative to which the widget is placed
2649-
in_=master - see 'in' option description
2650-
x=amount - locate anchor of this widget at position x of master
2651-
y=amount - locate anchor of this widget at position y of master
2653+
in=container - the container widget relative to which this widget is
2654+
placed
2655+
in_=container - see 'in' option description
2656+
x=amount - locate anchor of this widget at position x of the
2657+
container widget
2658+
y=amount - locate anchor of this widget at position y of the
2659+
container widget
26522660
relx=amount - locate anchor of this widget between 0.0 and 1.0
2653-
relative to width of master (1.0 is right edge)
2661+
relative to width of the container widget (1.0 is
2662+
right edge)
26542663
rely=amount - locate anchor of this widget between 0.0 and 1.0
2655-
relative to height of master (1.0 is bottom edge)
2656-
anchor=NSEW (or subset) - position anchor according to given direction
2664+
relative to height of the container widget (1.0 is
2665+
bottom edge)
2666+
anchor=NSEW (or subset) - position anchor according to given
2667+
direction
26572668
width=amount - width of this widget in pixel
26582669
height=amount - height of this widget in pixel
26592670
relwidth=amount - width of this widget between 0.0 and 1.0
2660-
relative to width of master (1.0 is the same width
2661-
as the master)
2671+
relative to width of the container widget (1.0 is
2672+
the same width as the container widget)
26622673
relheight=amount - height of this widget between 0.0 and 1.0
2663-
relative to height of master (1.0 is the same
2664-
height as the master)
2674+
relative to height of the container widget (1.0
2675+
is the same height as the container widget)
26652676
bordermode="inside" or "outside" - whether to take border width of
2666-
master widget into account
2677+
the container widget into account
26672678
"""
26682679
self.tk.call(
26692680
('place', 'configure', self._w)
@@ -2699,8 +2710,8 @@ def grid_configure(self, cnf={}, **kw):
26992710
"""Position a widget in the parent widget in a grid. Use as options:
27002711
column=number - use cell identified with given column (starting with 0)
27012712
columnspan=number - this widget will span several columns
2702-
in=master - use master to contain this widget
2703-
in_=master - see 'in' option description
2713+
in=container - use the container widget to contain this widget
2714+
in_=container - see 'in' option description
27042715
ipadx=amount - add internal padding in x direction
27052716
ipady=amount - add internal padding in y direction
27062717
padx=amount - add padding in x direction

0 commit comments

Comments
 (0)