From 289c027af8c76ed8c0ac0d1236c6c1032647f33c Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Sat, 27 Jun 2026 14:18:27 +0300 Subject: [PATCH] gh-70273: Document default class bindings in tkinter Note in the Bindings and events section that every widget inherits Tk class bindings for its standard behavior, where they are documented, and how to suppress an unwanted one by returning "break" from a callback. Co-Authored-By: Claude Opus 4.8 --- Doc/library/tkinter.rst | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Doc/library/tkinter.rst b/Doc/library/tkinter.rst index 5fe1ed7474cf367..1015ee407c00035 100644 --- a/Doc/library/tkinter.rst +++ b/Doc/library/tkinter.rst @@ -883,6 +883,20 @@ they are denoted in Tk, which can be useful when referring to the Tk man pages. | %d | detail | %D | delta | +----+---------------------+----+---------------------+ +The ``add`` parameter above only affects the bindings you make yourself. +Every widget also inherits *class bindings* +that implement its standard behavior -- +for example a :class:`Text` widget binds :kbd:`Control-t` +to transpose two characters. +These are described in the bindings section of the widget's Tk man page +(such as :manpage:`text(3tk)` or :manpage:`entry(3tk)`). + +Class bindings are processed separately from your own, +so binding an event yourself does not replace the default; both run. +To suppress an unwanted default binding, +bind the event on the widget +and return the string ``"break"`` from your callback. + The index parameter ^^^^^^^^^^^^^^^^^^^