]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.15] gh-86726: Fix and improve tkinter documentation and docstrings (GH-153549...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Sat, 11 Jul 2026 10:17:25 +0000 (12:17 +0200)
committerGitHub <noreply@github.com>
Sat, 11 Jul 2026 10:17:25 +0000 (10:17 +0000)
Correct inaccurate return-type and option descriptions in the tkinter
reference, and add missing module and class docstrings.
(cherry picked from commit 77cb7560c07feed0d5b144c0c1735e1620c96f51)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Doc/library/dialog.rst
Doc/library/tkinter.messagebox.rst
Doc/library/tkinter.rst
Doc/library/tkinter.ttk.rst
Lib/tkinter/__init__.py
Lib/tkinter/colorchooser.py
Lib/tkinter/commondialog.py
Lib/tkinter/dialog.py
Lib/tkinter/font.py
Lib/tkinter/messagebox.py
Lib/tkinter/simpledialog.py

index 384a1eacc2d7ccb8ead7e827c4f685314dfefd54..c50232f1d029cda614a6c7d886f0ef17170d9f6e 100644 (file)
@@ -175,19 +175,16 @@ specific value.
 
 .. class:: Open(master=None, **options)
            SaveAs(master=None, **options)
+           Directory(master=None, **options)
 
-   The above two classes provide native dialog windows for saving and loading
-   files.
+   The above three classes provide native dialog windows for loading and saving
+   files and for selecting a directory.
 
 **Convenience classes**
 
 The below classes are used for creating file/directory windows from scratch.
 These do not emulate the native look-and-feel of the platform.
 
-.. class:: Directory(master=None, **options)
-
-   Create a dialog prompting the user to select a directory.
-
 .. note::  The *FileDialog* class should be subclassed for custom event
    handling and behaviour.
 
@@ -311,23 +308,25 @@ the classic (non-themed) Tk widgets.
 
 .. data:: DIALOG_ICON
 
-   The name of the default bitmap (``'questhead'``) displayed by a
-   :class:`Dialog`.
+   The name of a bitmap (``'questhead'``) suitable for use as the *bitmap*
+   of a :class:`Dialog`.
 
 .. class:: Dialog(master=None, cnf={}, **kw)
 
    Display a modal dialog box built from the classic (non-themed) Tk widgets
    and wait for the user to press one of its buttons.
-   The options, given through *cnf* or as keyword arguments, include *title*
-   (the window title), *text* (the message), *bitmap* (an icon,
-   :data:`DIALOG_ICON` by default), *default* (the index of the default button)
-   and *strings* (the sequence of button labels).
+   The options, given through *cnf* or as keyword arguments, are all required:
+   *title* (the window title), *text* (the message), *bitmap* (the name of a
+   bitmap icon, such as :data:`DIALOG_ICON`), *default* (the index of the
+   default button) and *strings* (the sequence of button labels).
    After construction, the :attr:`!num` attribute holds the index of the button
    the user pressed.
 
    .. method:: destroy()
 
-      Destroy the dialog window.
+      Do nothing.
+      The dialog window is destroyed automatically before the constructor
+      returns, so there is nothing left for this method to do.
 
 
 .. seealso::
index 7fd561ade2f8bc5556757eab1c9e9a3db98b43c7..47fe680bac9107e10de93a37d75f24300d0a4db4 100644 (file)
@@ -13,9 +13,7 @@ a variety of convenience methods for commonly used configurations.
 The message boxes are modal: each blocks until the user responds, then returns
 a value that depends on the function.
 The ``show*`` functions and :meth:`Message.show` return the symbolic name of
-the button the user pressed, as a string (such as :data:`OK` or :data:`YES`),
-while the ``ask*`` functions return a :class:`bool` or ``None`` (see each
-function below).
+the button the user pressed, as a string (such as :data:`OK` or :data:`YES`).
 Common message box styles and layouts include but are not limited to:
 
 .. figure:: tk_msg.png
index f28e6706e22cbb6ca6e2b7109b30ab365f9adfb6..ce68f0389b9c30809df220ad2a706c7a6495968b 100644 (file)
@@ -2280,8 +2280,8 @@ Base and mixin classes
       If all four arguments are given, the window manager keeps the ratio
       between ``minNumer/minDenom`` and ``maxNumer/maxDenom``; passing empty
       strings removes any existing restriction.
-      With no arguments, return a tuple of the four current values, or an empty
-      string if no aspect restriction is in effect.
+      With no arguments, return a tuple of the four current values, or ``None``
+      if no aspect restriction is in effect.
       :meth:`wm_aspect` is an alias of :meth:`!aspect`.
 
    .. method:: wm_attributes(*args, return_python_dict=False, **kwargs)
@@ -2506,8 +2506,8 @@ Base and mixin classes
       window's internally requested size, and *widthInc* and *heightInc* are
       the pixel sizes of a horizontal and vertical grid unit.
       Empty strings turn off gridded management.
-      With no arguments, return a tuple of the four current values, or an empty
-      string if the window is not gridded.
+      With no arguments, return a tuple of the four current values, or ``None``
+      if the window is not gridded.
       :meth:`wm_grid` is an alias of :meth:`!grid`.
 
       Not to be confused with the grid geometry manager :meth:`Grid.grid`.
@@ -2602,8 +2602,8 @@ Base and mixin classes
       Set or query a hint to the window manager about where the window's icon
       should be positioned.
       Empty strings cancel an existing hint.
-      With no arguments, return a tuple of the two current values, or an empty
-      string if no hint is in effect.
+      With no arguments, return a tuple of the two current values, or ``None``
+      if no hint is in effect.
       :meth:`wm_iconposition` is an alias of :meth:`!iconposition`.
 
    .. method:: wm_iconwindow(pathName=None)
@@ -2672,7 +2672,8 @@ Base and mixin classes
       When this flag is set, the window is ignored by the window manager: it is
       not reparented into a decorative frame and the user cannot manipulate it
       through the usual window manager controls.
-      With no argument, return a boolean indicating whether the flag is set.
+      With no argument, return a boolean indicating whether the flag is set,
+      or ``None`` if it has not been set.
       The flag is reliably honored only when the window is first mapped or
       remapped from the withdrawn state.
       :meth:`wm_overrideredirect` is an alias of :meth:`!overrideredirect`.
index 13fead3e65ece78d46aa205c480d5c31d8146e61..54066625e82c0635928c683a76cfaa2e4bf5e641 100644 (file)
@@ -42,8 +42,9 @@ To override the basic Tk widgets, the import should follow the Tk import::
 
 That code causes several :mod:`!tkinter.ttk` widgets (:class:`Button`,
 :class:`Checkbutton`, :class:`Entry`, :class:`Frame`, :class:`Label`,
-:class:`LabelFrame`, :class:`Menubutton`, :class:`PanedWindow`,
-:class:`Radiobutton`, :class:`Scale` and :class:`Scrollbar`) to
+:class:`LabelFrame`, :class:`Menubutton`, :class:`OptionMenu`,
+:class:`PanedWindow`, :class:`Radiobutton`, :class:`Scale`,
+:class:`Scrollbar` and :class:`Spinbox`) to
 automatically replace the Tk widgets.
 
 This has the direct benefit of using the new widgets which gives a better look
@@ -1039,6 +1040,9 @@ ttk.Treeview
          The minimum width of the column in pixels. The treeview widget will
          not make the column any smaller than specified by this option when
          the widget is resized or the user drags a column.
+      *separator*: ``True``/``False``
+         Specifies whether a column separator should be drawn to the right of
+         the column.
       *stretch*: ``True``/``False``
          Specifies whether the column's width should be adjusted when
          the widget is resized.
@@ -1752,8 +1756,11 @@ and inherits the common methods of :class:`Widget`.
    display in the menu.
    A *command* keyword argument may be given to specify a callable that is
    invoked with the selected value whenever the selection changes; the *style*
-   keyword argument sets the style used by the underlying menubutton; and the
-   *name* keyword argument sets the Tk widget name.
+   keyword argument sets the style used by the underlying menubutton; the
+   *direction* keyword argument sets where the menu is posted relative to the
+   menubutton (one of ``'above'``, ``'below'`` (the default), ``'left'``,
+   ``'right'`` or ``'flush'``); and the *name* keyword argument sets the Tk
+   widget name.
 
    .. method:: set_menu(default=None, *values)
 
index 3b693bc72f57238e04f7d2ff60af7c5a7d310d9b..63b08b3e82d4dadf40a48dcbf3b481fc99cd7d45 100644 (file)
@@ -3,7 +3,7 @@
 Tkinter provides classes which allow the display, positioning and
 control of widgets. Toplevel widgets are Tk and Toplevel. Other
 widgets are Frame, Label, Entry, Text, Canvas, Button, Radiobutton,
-Checkbutton, Scale, Listbox, Scrollbar, OptionMenu, Spinbox
+Checkbutton, Scale, Listbox, Scrollbar, OptionMenu, Spinbox,
 LabelFrame and PanedWindow.
 
 Properties of the widgets are specified with keyword arguments.
@@ -2436,7 +2436,7 @@ class Wm:
 
     def wm_iconposition(self, x=None, y=None):
         """Set the position of the icon of this widget to X and Y. Return
-        a tuple of the current values of X and X if None is given."""
+        a tuple of the current values of X and Y if None is given."""
         return self._getints(self.tk.call(
             'wm', 'iconposition', self._w, x, y))
 
index e2fb69dba927633e614d9438a20ecee6de6b7260..4085bde1637a79f8fc7d0eae11c6f79ebe2e26c9 100644 (file)
@@ -1,3 +1,5 @@
+"""Interface to the native Tk color selection dialog."""
+
 # tk common color chooser dialogue
 #
 # this module provides an interface to the native color dialogue
index 86f5387e001bf28a4c073b4e75316b8ac138845d..408cedc345def634d76a4be42d54fe2048b4455f 100644 (file)
@@ -1,3 +1,5 @@
+"""Base class for the Tk common dialogs."""
+
 # base class for tk common dialogues
 #
 # this module provides a base class for accessing the common
index 36ae6c277cb66ac86a48f42d07ce4c08dce10738..ef005af0d5a19c0b5455720a9b20af0feab7d10c 100644 (file)
@@ -1,5 +1,7 @@
 # dialog.py -- Tkinter interface to the tk_dialog script.
 
+"""Classic Tk dialog box, wrapping the tk_dialog script."""
+
 from tkinter import _cnfmerge, Widget, TclError, Button, Pack
 
 __all__ = ["Dialog"]
@@ -8,6 +10,8 @@ DIALOG_ICON = 'questhead'
 
 
 class Dialog(Widget):
+    """A modal dialog box built from the classic (non-themed) Tk widgets."""
+
     def __init__(self, master=None, cnf={}, **kw):
         cnf = _cnfmerge((cnf, kw))
         self.widgetName = '__dialog__'
@@ -21,7 +25,8 @@ class Dialog(Widget):
         try: Widget.destroy(self)
         except TclError: pass
 
-    def destroy(self): pass
+    def destroy(self):
+        """Do nothing; the dialog window is already destroyed."""
 
 
 def _test():
index 1face04279af7ff6c3750f664631e197e54304b3..2bbdbd560436af7bcec9d687da8092f53ebfe888 100644 (file)
@@ -1,3 +1,5 @@
+"""Utilities to help work with fonts in Tkinter."""
+
 # Tkinter font wrapper
 #
 # written by Fredrik Lundh, February 1998
index dd2816cffb1140ba3c5c9db668e89a1b64373080..f6848142a9aff62ecdc4c5e70cf27d056aba0a8a 100644 (file)
@@ -1,3 +1,5 @@
+"""Interface to the standard Tk message boxes."""
+
 # tk common message boxes
 #
 # this module provides an interface to the native message boxes
index 4f9eb44f034677322f19fa6bb678b229d4a0c736..b9710a98ed0b92bd7919107d7b047334eb6fcb6d 100644 (file)
@@ -8,7 +8,7 @@
 # fredrik@pythonware.com
 # http://www.pythonware.com
 #
-"""This modules handles dialog boxes.
+"""This module handles dialog boxes.
 
 It contains the following public symbols: