Events#

The catalog of tkinter’s event system: every event type, modifier, and key symbol you can name in a pattern, every attribute of the event object a callback receives, the options for synthesizing events, and the built-in <<virtual>> event names.

Note

This is standard tkinter — it comes from Tk’s bind and event commands, which Tk documents only in C-oriented manual pages. This reference restates the names in Python terms. For how to use them — binding callbacks, stopping propagation, and generating your own events — see Events & callbacks in the User Guide.

Pattern grammar#

An event pattern names which event fires a callback. Its full form is one or more modifiers, a type, and an optional detail, inside angle brackets:

<Control-Shift-KeyPress-Q>
 │       │     │        └─ detail     which key or button
 │       │     └───────── type        the kind of event
 └───────┴─────────────── modifiers   keys/buttons held down
  • The type is required unless it can be inferred: a bare detail like <1> means <Button-1> and <q> means <KeyPress-q>.

  • Detail is a button number for button events or a key symbol for key events; omit it to match any button or key.

  • A <<Name>> pattern (double brackets) is a virtual event; modifiers may not be combined with one.

Event types

Every event type token — KeyPress, Button, Motion, Configure, <<virtual>> — and when each fires.

Event types
Modifiers & keys

The modifier tokens (Control, Shift, Double, …) and the common key symbols used as the detail of a key event.

Modifiers & keys
The event object

Every attribute of the event passed to a callback, the Tk field it maps to, and which event types populate it.

The event object
event_generate options

The keyword options accepted by event_generate and the when scheduling values.

event_generate options
Built-in virtual events

The predefined <<virtual>> events Tk, ttk, and ttkbootstrap emit.

Built-in virtual events