Skip to content

Commit 5e494ba

Browse files
serhiy-storchakamiss-islington
authored andcommitted
gh-143754: Modernize Tkinter docs (GH-143841)
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 22e4d55 commit 5e494ba

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
@@ -175,12 +175,12 @@ the modern themed widget set and API::
175175
.. attribute:: master
176176

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

185185
.. attribute:: children
186186

@@ -636,15 +636,15 @@ The Packer
636636
.. index:: single: packing (widgets)
637637

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

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

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

676676
expand
677677
Boolean, ``0`` or ``1``.
@@ -680,10 +680,10 @@ fill
680680
Legal values: ``'x'``, ``'y'``, ``'both'``, ``'none'``.
681681

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

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

688688
side
689689
Legal values are: ``'left'``, ``'right'``, ``'top'``, ``'bottom'``.
@@ -756,8 +756,8 @@ subclassed from the :class:`Wm` class, and so can call the :class:`Wm` methods
756756
directly.
757757

758758
To get at the toplevel window that contains a given widget, you can often just
759-
refer to the widget's master. Of course if the widget has been packed inside of
760-
a frame, the master won't represent a toplevel window. To get at the toplevel
759+
refer to the widget's :attr:`master`. Of course if the widget has been packed inside of
760+
a frame, the :attr:`!master` won't represent a toplevel window. To get at the toplevel
761761
window that contains an arbitrary widget, you can call the :meth:`_root` method.
762762
This method begins with an underscore to denote the fact that this function is
763763
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
@@ -1852,15 +1852,15 @@ def __repr__(self):
18521852
return '<%s.%s object %s>' % (
18531853
self.__class__.__module__, self.__class__.__qualname__, self._w)
18541854

1855-
# Pack methods that apply to the master
1855+
# Pack methods that apply to the container widget
18561856
_noarg_ = ['_noarg_']
18571857

18581858
def pack_propagate(self, flag=_noarg_):
18591859
"""Set or get the status for propagation of geometry information.
18601860
1861-
A boolean argument specifies whether the geometry information
1862-
of the slaves will determine the size of this widget. If no argument
1863-
is given the current setting will be returned.
1861+
A boolean argument specifies whether the size of this container will
1862+
be determined by the geometry information of its content.
1863+
If no argument is given the current setting will be returned.
18641864
"""
18651865
if flag is Misc._noarg_:
18661866
return self._getboolean(self.tk.call(
@@ -1871,28 +1871,28 @@ def pack_propagate(self, flag=_noarg_):
18711871
propagate = pack_propagate
18721872

18731873
def pack_slaves(self):
1874-
"""Return a list of all slaves of this widget
1875-
in its packing order."""
1874+
"""Returns a list of all of the content widgets in the packing order
1875+
for this container."""
18761876
return [self._nametowidget(x) for x in
18771877
self.tk.splitlist(
18781878
self.tk.call('pack', 'slaves', self._w))]
18791879

18801880
slaves = pack_slaves
18811881

1882-
# Place method that applies to the master
1882+
# Place method that applies to the container widget
18831883
def place_slaves(self):
1884-
"""Return a list of all slaves of this widget
1885-
in its packing order."""
1884+
"""Returns a list of all the content widgets for which this widget is
1885+
the container."""
18861886
return [self._nametowidget(x) for x in
18871887
self.tk.splitlist(
18881888
self.tk.call(
18891889
'place', 'slaves', self._w))]
18901890

1891-
# Grid methods that apply to the master
1891+
# Grid methods that apply to the container widget
18921892

18931893
def grid_anchor(self, anchor=None): # new in Tk 8.5
18941894
"""The anchor value controls how to place the grid within the
1895-
master when no row/column has any weight.
1895+
container widget when no row/column has any weight.
18961896
18971897
The default anchor is nw."""
18981898
self.tk.call('grid', 'anchor', self._w, anchor)
@@ -1909,7 +1909,7 @@ def grid_bbox(self, column=None, row=None, col2=None, row2=None):
19091909
starts at that cell.
19101910
19111911
The returned integers specify the offset of the upper left
1912-
corner in the master widget and the width and height.
1912+
corner in the container widget and the width and height.
19131913
"""
19141914
args = ('grid', 'bbox', self._w)
19151915
if column is not None and row is not None:
@@ -1967,7 +1967,7 @@ def grid_columnconfigure(self, index, cnf={}, **kw):
19671967

19681968
def grid_location(self, x, y):
19691969
"""Return a tuple of column and row which identify the cell
1970-
at which the pixel at position X and Y inside the master
1970+
at which the pixel at position X and Y inside the container
19711971
widget is located."""
19721972
return self._getints(
19731973
self.tk.call(
@@ -1976,9 +1976,9 @@ def grid_location(self, x, y):
19761976
def grid_propagate(self, flag=_noarg_):
19771977
"""Set or get the status for propagation of geometry information.
19781978
1979-
A boolean argument specifies whether the geometry information
1980-
of the slaves will determine the size of this widget. If no argument
1981-
is given, the current setting will be returned.
1979+
A boolean argument specifies whether the size of this container will
1980+
be determined by the geometry information of its content.
1981+
If no argument is given the current setting will be returned.
19821982
"""
19831983
if flag is Misc._noarg_:
19841984
return self._getboolean(self.tk.call(
@@ -2004,8 +2004,13 @@ def grid_size(self):
20042004
size = grid_size
20052005

20062006
def grid_slaves(self, row=None, column=None):
2007-
"""Return a list of all slaves of this widget
2008-
in its packing order."""
2007+
"""Returns a list of the content widgets.
2008+
2009+
If no arguments are supplied, a list of all of the content in this
2010+
container widget is returned, most recently managed first.
2011+
If ROW or COLUMN is specified, only the content in the row or
2012+
column is returned.
2013+
"""
20092014
args = ()
20102015
if row is not None:
20112016
args = args + ('-row', row)
@@ -2591,8 +2596,8 @@ def pack_configure(self, cnf={}, **kw):
25912596
before=widget - pack it before you will pack widget
25922597
expand=bool - expand widget if parent size grows
25932598
fill=NONE or X or Y or BOTH - fill widget if widget grows
2594-
in=master - use master to contain this widget
2595-
in_=master - see 'in' option description
2599+
in=container - use the container widget to contain this widget
2600+
in_=container - see 'in' option description
25962601
ipadx=amount - add internal padding in x direction
25972602
ipady=amount - add internal padding in y direction
25982603
padx=amount - add padding in x direction
@@ -2631,25 +2636,31 @@ class Place:
26312636

26322637
def place_configure(self, cnf={}, **kw):
26332638
"""Place a widget in the parent widget. Use as options:
2634-
in=master - master relative to which the widget is placed
2635-
in_=master - see 'in' option description
2636-
x=amount - locate anchor of this widget at position x of master
2637-
y=amount - locate anchor of this widget at position y of master
2639+
in=container - the container widget relative to which this widget is
2640+
placed
2641+
in_=container - see 'in' option description
2642+
x=amount - locate anchor of this widget at position x of the
2643+
container widget
2644+
y=amount - locate anchor of this widget at position y of the
2645+
container widget
26382646
relx=amount - locate anchor of this widget between 0.0 and 1.0
2639-
relative to width of master (1.0 is right edge)
2647+
relative to width of the container widget (1.0 is
2648+
right edge)
26402649
rely=amount - locate anchor of this widget between 0.0 and 1.0
2641-
relative to height of master (1.0 is bottom edge)
2642-
anchor=NSEW (or subset) - position anchor according to given direction
2650+
relative to height of the container widget (1.0 is
2651+
bottom edge)
2652+
anchor=NSEW (or subset) - position anchor according to given
2653+
direction
26432654
width=amount - width of this widget in pixel
26442655
height=amount - height of this widget in pixel
26452656
relwidth=amount - width of this widget between 0.0 and 1.0
2646-
relative to width of master (1.0 is the same width
2647-
as the master)
2657+
relative to width of the container widget (1.0 is
2658+
the same width as the container widget)
26482659
relheight=amount - height of this widget between 0.0 and 1.0
2649-
relative to height of master (1.0 is the same
2650-
height as the master)
2660+
relative to height of the container widget (1.0
2661+
is the same height as the container widget)
26512662
bordermode="inside" or "outside" - whether to take border width of
2652-
master widget into account
2663+
the container widget into account
26532664
"""
26542665
self.tk.call(
26552666
('place', 'configure', self._w)
@@ -2685,8 +2696,8 @@ def grid_configure(self, cnf={}, **kw):
26852696
"""Position a widget in the parent widget in a grid. Use as options:
26862697
column=number - use cell identified with given column (starting with 0)
26872698
columnspan=number - this widget will span several columns
2688-
in=master - use master to contain this widget
2689-
in_=master - see 'in' option description
2699+
in=container - use the container widget to contain this widget
2700+
in_=container - see 'in' option description
26902701
ipadx=amount - add internal padding in x direction
26912702
ipady=amount - add internal padding in y direction
26922703
padx=amount - add padding in x direction

0 commit comments

Comments
 (0)