From the course: Python GUI Development with Tkinter

Unlock the full course today

Join today to access over 22,700 courses taught by industry experts or purchase this course individually.

Binding to multiple events

Binding to multiple events

From the course: Python GUI Development with Tkinter

Start my 1-month free trial

Binding to multiple events

- [Instructor] Thus far, we've only used the bind method to configure event handlers for single instances of widgets. In this video, I'm going to teach you about how widgets react if they're bound to multiple similar events, and how you can create a single event binding which is tied to multiple widgets within the program. I'll start by accessing the exercise files, in the chapter seven directory, and creating a copy of the template Python file. I'll rename that copy to 05_multiple, and then right-click on it and choose edit with idle. To demonstrate multiple event bindings, I'm going to start by creating two label widgets. Label one, which is a child of the root and has the text label one on it. And then I'll just copy that line and create a similar label two. And of course I also need to add those to the window, and I'll do so with the pac command. Now, let's add an event binding to label one that'll print a message when it's clicked on. I can do that by typing label one dot bind…

Contents