From the course: Python GUI Development with Tkinter
Unlock the full course today
Join today to access over 24,900 courses taught by industry experts.
Binding to keyboard events
From the course: Python GUI Development with Tkinter
Binding to keyboard events
- [Instructor] In the previous video, we learned about command callbacks, which are a great way to trigger code to be executed based on user events. However, command callbacks are only available for specific actions with a handful of widgets. For example, clicking on a button. There may be times when we want to trigger events based on other user actions with the mouse or keyboard. To do that in Tkinter, we can bind our program to different types of events, and specify the handler function or method to be executed when that event occurs. There's a wide variety of event types that you can bind your program to with Tkinter. In this video and the next one, I'll focus on Tk events related to inputs from the keyboard and mouse, because those are the types of events that you will most frequently bind to in your program. If you want to learn more about the other types of events that Tk generates, you can read about them in the Tcl/Tk documentation on the bind command. For this example, I'm…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.