Skip to content

Commit 794689b

Browse files
gh-153550: Modernize the older prose sections of the tkinter documentation
Refresh the narrative "Tkinter life preserver" and "Handy reference" sections to match the overhauled reference (gh-86726 and gh-153549). * Rework "The packer" into a general "Geometry management" section that covers grid, pack and place, with a short example and use case for each, presents grid as the flexible default, and warns against mixing pack and grid in one container. Add symmetric cross-links between the Grid, Pack and Place reference classes and this section. * Rework "The window manager": explain what the window manager is, state that the Wm mixin is inherited by Tk and Toplevel so its methods are called directly on a top-level window, and replace the dated App(Frame) example (which reached the window through master) with a direct Tk() example. Drop the private _root() aside and cross-link the section and the Wm reference class to each other. * Rework "Coupling widget variables": explain that a widget links to a Variable object rather than a plain Python variable because Python cannot notify Tk when a variable is reassigned, and replace the dated App(Frame) example (whose entry was attached to the wrong parent) with a direct ttk example showing both get() and set(). * Remove the page-number citations to Ousterhout's book and point to the relevant Tk man pages instead. * Refresh the Tcl/Tk links in tkinter.ttk: add the official ttk::intro man page as the current explanation of the theme engine, keep Joe English's illustrated 2004 "Tile Widget Set" paper for its element and layout diagrams, and drop the now-redundant conversion monograph. * Modernize the tkinter.ttk front matter: lead the introduction with the native-theme benefit instead of peripheral features, update the TIP 48 link to its canonical URL, and add a note recommending the explicit "from tkinter import ttk" form over the star-import override. * Add cross-references between the two documents: point the tkinter.ttk introduction at the shared concepts documented for tkinter, and link the themed-widgets note in the tkinter introduction to tkinter.ttk. * Reconcile the "Packer options" and "Tk option data types" lists with the reference: replace the incomplete packer list with a cross-link to Pack.pack_configure, and frame the data-types list as the shared value types the reference refers to. * Fill in the empty Entry index list under "The index parameter", and describe "@6" as a string rather than an integer. * Point the classic base-widget examples at the themed ttk widgets. * Fix the malformed target-selection list in tkinter.dnd: make it a single ordered list with the sub-steps nested under the search step, and mark up "source" and "event" as parameters. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent dd2faeb commit 794689b

3 files changed

Lines changed: 221 additions & 157 deletions

File tree

Doc/library/tkinter.dnd.rst

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,22 @@ a single application, within the same window or between windows. To enable an
1616
object to be dragged, you must create an event binding for it that starts the
1717
drag-and-drop process. Typically, you bind a ButtonPress event to a callback
1818
function that you write (see :ref:`Bindings-and-Events`). The function should
19-
call :func:`dnd_start`, where 'source' is the object to be dragged, and 'event'
19+
call :func:`dnd_start`, where *source* is the object to be dragged, and *event*
2020
is the event that invoked the call (the argument to your callback function).
2121

2222
Selection of a target object occurs as follows:
2323

24-
#. Top-down search of area under mouse for target widget
24+
#. Top-down search of the area under the mouse for a target widget:
2525

26-
* Target widget should have a callable *dnd_accept* attribute
27-
* If *dnd_accept* is not present or returns ``None``, search moves to parent widget
28-
* If no target widget is found, then the target object is ``None``
26+
* the target widget should have a callable *dnd_accept* attribute;
27+
* if *dnd_accept* is not present or returns ``None``,
28+
the search moves to the parent widget;
29+
* if no target widget is found, the target object is ``None``.
2930

30-
2. Call to *<old_target>.dnd_leave(source, event)*
31-
#. Call to *<new_target>.dnd_enter(source, event)*
32-
#. Call to *<target>.dnd_commit(source, event)* to notify of drop
33-
#. Call to *<source>.dnd_end(target, event)* to signal end of drag-and-drop
31+
#. Call to ``<old_target>.dnd_leave(source, event)``.
32+
#. Call to ``<new_target>.dnd_enter(source, event)``.
33+
#. Call to ``<target>.dnd_commit(source, event)`` to notify of the drop.
34+
#. Call to ``<source>.dnd_end(target, event)`` to signal the end of drag-and-drop.
3435

3536

3637
.. class:: DndHandler(source, event)

0 commit comments

Comments
 (0)