Next / Previous / Contents

54.3. Event types

The full set of event types is rather large, but a lot of them are not commonly used. Here are most of the ones you'll need:

TypeNameDescription
36 Activate A widget is changing from being inactive to being active. This refers to changes in the state option of a widget such as a button changing from inactive (grayed out) to active.
4 Button The user pressed one of the mouse buttons. The detail part specifies which button. For mouse wheel support under Linux, use Button-4 (scroll up) and Button-5 (scroll down). Under Linux, your handler for mouse wheel bindings will distinguish between scroll-up and scroll-down by examining the .num field of the Event instance; see Section 54.6, “Writing your handler: The Event class”.
5 ButtonRelease The user let up on a mouse button. This is probably a better choice in most cases than the Button event, because if the user accidentally presses the button, they can move the mouse off the widget to avoid setting off the event.
22 Configure The user changed the size of a widget, for example by dragging a corner or side of the window.
37 Deactivate A widget is changing from being active to being inactive. This refers to changes in the state option of a widget such as a radiobutton changing from active to inactive (grayed out).
17 Destroy A widget is being destroyed.
7 Enter The user moved the mouse pointer into a visible part of a widget. (This is different than the enter key, which is a KeyPress event for a key whose name is actually 'return'.)
12 Expose This event occurs whenever at least some part of your application or widget becomes visible after having been covered up by another window.
9 FocusIn A widget got the input focus (see Section 53, “Focus: routing keyboard input” for a general introduction to input focus.) This can happen either in response to a user event (like using the tab key to move focus between widgets) or programmatically (for example, your program calls the .focus_set() on a widget).
10 FocusOut The input focus was moved out of a widget. As with FocusIn, the user can cause this event, or your program can cause it.
2 KeyPress The user pressed a key on the keyboard. The detail part specifies which key. This keyword may be abbreviated Key.
3 KeyRelease The user let up on a key.
8 Leave The user moved the mouse pointer out of a widget.
19 Map A widget is being mapped, that is, made visible in the application. This will happen, for example, when you call the widget's .grid() method.
6 Motion The user moved the mouse pointer entirely within a widget.
38 MouseWheel The user moved the mouse wheel up or down. At present, this binding works on Windows and MacOS, but not under Linux. For Windows and MacOS, see the discussion of the .delta field of the Event instance in Section 54.6, “Writing your handler: The Event class”. For Linux, see the note above under Button.
18 Unmap A widget is being unmapped and is no longer visible. This happens, for example, when you use the widget's .grid_remove() method.
15 Visibility Happens when at least some part of the application window becomes visible on the screen.