Tkinter Widget Introduction
After the Tkinter window is created, the next step is to create controls inside the window, which we will collectively call Widgets.
(1) Button
(2) Canvas
(3) Checkbutton (multi-select button)
(4) Entry (text box)
(5) Frame
(6) Label
(7) LabelFrame
(8) Listbox
(9) Menu
(10) MenuButton: This is an obsolete control that has been replaced by Menu().
(11) Message
(12) OptionMenu
(13) PanedWindow
(14) Radiobutton
(15) Scale
(16) Scrollbar
(17) Spinbox
(18) Text
(19) Toplevel
The Tkinter Tutorial will introduce the above controls one by one, and interspersed throughout the chapters will be the Widget Layout Manager, Image, and Event. The last thing the reader needs to know is that all widgets in tkinter are actually object-oriented classes, and we call the constructor methods to create the relevant widget controls.
Enhanced version of the tkinter module
tkinter also introduced an enhanced version of the module later on, called tkinter.ttk.
The following are the widgets that were originally available in tkinter:
(1)Button
(2)Checkbutton
(3)Entry
(4)Frame
(5)Label
(6)LabelFrame
(7)MenuButton
(8)Radiobutton
(9)Scale
(10)Scrollbar
(11)PanedWindow
The following widgets are added to the ttk module:
(1)Combobox
(2)Notebook
(3)Progressbar
(4)Separator
(5)Sizegrip:You can change the size of the topmost window by dragging the bottom right of the topmost window.
(6)Treeview
Importing the above modules can be done in the following way.
from tkinter import ttk
If you import ttk using the following method, you can overwrite the original tkinter controls.
from tkinter import *
from tkinter.ttk import *
Using ttk can have a better appearance and it can also be used cross-platform, although it is not 100% compatible. For example, fg, bg parameters or some appearance related parameters tk and ttk are not the same. ttk uses the ttk.Style category.