O'Reilly logo

Tkinter GUI Programming by Example by David Love

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Binding an event

The basic format of an event binding is as follows:

widget.bind('<Event-String>', function_name)

Each widget has the ability to listen to the system for one of many event types. Each event type has a particular string defined within Tkinter to allow it to be mapped over to the Python interface. When the event passed via this string occurs, the function passed as the second parameter is executed. Note that the function is passed and not executed, just like the command argument of a Button widget.

When an application is written in an object-oriented manner, the function passed to the bind method is typically a regular class method. If the code is instead written procedurally, you will often see lambda functions used in order ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required