From the course: Python GUI Development with Tkinter

Unlock the full course today

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

Capturing input with buttons

Capturing input with buttons

From the course: Python GUI Development with Tkinter

Start my 1-month free trial

Capturing input with buttons

- [Instructor] Unlike labels, which merely display information, buttons are designed specifically for the user to interact with. They're one of the simplest ways for a user to provide input to your program. When the user clicks on a button, they expect something to happen. That means, in addition to defining the look and feel of a button, our program will also need to define the action it will perform when pressed. I'll begin by importing the tkinter package by calling from tkinter import asterisk. And I'll also import the themed ttk module from tkinter import ttk. After that, I'll call the tk constructor method to create my top level route window. And now, I'm ready to begin creating buttons. I'll create a button by calling the themed ttk button constructor method, and notice, button is spelled with a capital B. I'll pass in it's parent, which is the first parameter, as always. And then, I'll also configure the property for the button called text. And I'm going to make this button…

Contents