Skip to content

Commit 4fd69ef

Browse files
gh-70273: Document default class bindings in tkinter (GH-152389)
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 <noreply@anthropic.com>
1 parent ea7f64a commit 4fd69ef

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

Doc/library/tkinter.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -885,6 +885,20 @@ they are denoted in Tk, which can be useful when referring to the Tk man pages.
885885
| %d | detail | %D | delta |
886886
+----+---------------------+----+---------------------+
887887

888+
The ``add`` parameter above only affects the bindings you make yourself.
889+
Every widget also inherits *class bindings*
890+
that implement its standard behavior --
891+
for example a :class:`Text` widget binds :kbd:`Control-t`
892+
to transpose two characters.
893+
These are described in the bindings section of the widget's Tk man page
894+
(such as :manpage:`text(3tk)` or :manpage:`entry(3tk)`).
895+
896+
Class bindings are processed separately from your own,
897+
so binding an event yourself does not replace the default; both run.
898+
To suppress an unwanted default binding,
899+
bind the event on the widget
900+
and return the string ``"break"`` from your callback.
901+
888902

889903
The index parameter
890904
^^^^^^^^^^^^^^^^^^^

0 commit comments

Comments
 (0)