A widget is a graphical element inside a GUI window that displays information or lets users interact with a program. Buttons, menus, text boxes, labels, scrollbars, and canvases are widgets. section 37.1
Build a widget into a GUI in three steps:
- Create the widget, such as a Button, Entry, or Label. section 37.3
- Place it in the window with a layout method such as pack. section 37.3
- Connect an event handler when the widget should respond to an action such as a click or menu selection. section 37.1 section 37.4
A button that changes the window
import tkinter def change_color(): window.configure(background="white") window = tkinter.Tk() white = tkinter.Button(window, text="Click", command=change_color) white.pack() window.mainloop() The button is created with a parent window, given a label, and connected to change_color. Clicking it runs the function and changes the window background. section 37.4
Table 37.1. Widgets available in tkinter
Browse the tkinter widget table to compare controls such as Button, Entry, Label, Checkbutton, Radiobutton, Canvas, and Scrollbar. section 37.3

