Next / Previous / Contents

54. Events: responding to stimuli

An event is something that happens to your application—for example, the user presses a key or clicks or drags the mouse—to which the application needs to react.

The widgets normally have a lot of built-in behaviors. For example, a button will react to a mouse click by calling its command callback. For another example, if you move the focus to an entry widget and press a letter, that letter gets added to the content of the widget.

However, the event binding capability of Tkinter allows you to add, change, or delete behaviors.

First, some definitions:

  • An event is some occurrence that your application needs to know about.

  • An event handler is a function in your application that gets called when an event occurs.

  • We call it binding when your application sets up an event handler that gets called when an event happens to a widget.