Specifying an event sequence

To create an event with event_generate(), we need to pass in an event sequence string, in the format <EventModifier-EventType-EventDetail>.

Event type specifies the kind of event we're sending, such as a keystroke, mouse click, windowing event, and so on.

Tkinter has around 30 event types, but you will typically only need to work with the following:

Event types
Description
ButtonPress Also Button, represents a mouse button click
ButtonRelease Represents lifting off a mouse button
KeyPress Also Key, represents pressing a keyboard key
KeyRelease Represents lifting off a keyboard key
FocusIn Represents giving focus to a widget
FocusOut Represents exiting a widget
Enter Represents the mouse cursor ...

Get Python GUI Programming with Tkinter now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.