Skip to content

Commit 813fc7a

Browse files
gh-143754: Modernize Tkinter docs (GH-143841)
Use more relevant terminology instead of "master"/"slave" widgets where possible.
1 parent cb6a662 commit 813fc7a

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
@@ -1867,15 +1867,15 @@ def __repr__(self):
18671867
return '<%s.%s object %s>' % (
18681868
self.__class__.__module__, self.__class__.__qualname__, self._w)
18691869

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

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

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

18951895
slaves = pack_slaves
18961896

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

1906-
# Grid methods that apply to the master
1906+
# Grid methods that apply to the container widget
19071907

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

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

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

26472652
def place_configure(self, cnf={}, **kw):
26482653
"""Place a widget in the parent widget. Use as options:
2649-
in=master - master relative to which the widget is placed
2650-
in_=master - see 'in' option description
2651-
x=amount - locate anchor of this widget at position x of master
2652-
y=amount - locate anchor of this widget at position y of master
2654+
in=container - the container widget relative to which this widget is
2655+
placed
2656+
in_=container - see 'in' option description
2657+
x=amount - locate anchor of this widget at position x of the
2658+
container widget
2659+
y=amount - locate anchor of this widget at position y of the
2660+
container widget
26532661
relx=amount - locate anchor of this widget between 0.0 and 1.0
2654-
relative to width of master (1.0 is right edge)
2662+
relative to width of the container widget (1.0 is
2663+
right edge)
26552664
rely=amount - locate anchor of this widget between 0.0 and 1.0
2656-
relative to height of master (1.0 is bottom edge)
2657-
anchor=NSEW (or subset) - position anchor according to given direction
2665+
relative to height of the container widget (1.0 is
2666+
bottom edge)
2667+
anchor=NSEW (or subset) - position anchor according to given
2668+
direction
26582669
width=amount - width of this widget in pixel
26592670
height=amount - height of this widget in pixel
26602671
relwidth=amount - width of this widget between 0.0 and 1.0
2661-
relative to width of master (1.0 is the same width
2662-
as the master)
2672+
relative to width of the container widget (1.0 is
2673+
the same width as the container widget)
26632674
relheight=amount - height of this widget between 0.0 and 1.0
2664-
relative to height of master (1.0 is the same
2665-
height as the master)
2675+
relative to height of the container widget (1.0
2676+
is the same height as the container widget)
26662677
bordermode="inside" or "outside" - whether to take border width of
2667-
master widget into account
2678+
the container widget into account
26682679
"""
26692680
self.tk.call(
26702681
('place', 'configure', self._w)
@@ -2700,8 +2711,8 @@ def grid_configure(self, cnf={}, **kw):
27002711
"""Position a widget in the parent widget in a grid. Use as options:
27012712
column=number - use cell identified with given column (starting with 0)
27022713
columnspan=number - this widget will span several columns
2703-
in=master - use master to contain this widget
2704-
in_=master - see 'in' option description
2714+
in=container - use the container widget to contain this widget
2715+
in_=container - see 'in' option description
27052716
ipadx=amount - add internal padding in x direction
27062717
ipady=amount - add internal padding in y direction
27072718
padx=amount - add padding in x direction

0 commit comments

Comments
 (0)