Button: A standard clickable button that triggers an action when pressed.
Canvas: Used for drawing graphics, charts, and images, and for implementing custom widgets.
Checkbutton: A checkbox widget for on/off or true/false selections, allowing multiple options to be selected.
Entry: A single-line text entry field for user input.
Frame: A rectangular container used to group other widgets and provide structure or padding.
Label: Displays static text or images that the user cannot modify.
Listbox: Displays a list of options from which a user can select one or more items.
Menu: Used to create various types of menus, including top-level menus and dropdowns.
Menubutton: A button that, when clicked, displays a dropdown menu.
Message: Displays a multiline message or notification text.
PanedWindow: A container widget that allows the user to interactively resize the space allocated to its child widgets.
Radiobutton: Allows the user to choose only one option from a set of mutually exclusive choices.
Scale: Implements a graphical slider to select a numeric value from a range.
Scrollbar: Provides a scrolling mechanism for other widgets like Listbox, Text, or Canvas.
Text: A multiline text editor widget for formatted text display and editing.
Toplevel: A separate, top-level window with a title bar and borders, useful for dialog boxes or secondary application windows.
Outlines the frame for your Tkinter window with a fixed size. Just like the human skeleton, a Tkinter window requires a frame to support it and give it structure.
from tkinter import *
root = Tk()
root.geometry("200x150")
frame = Frame(root)
frame.pack()
leftframe = Frame(root)
leftframe.pack(side=LEFT)
rightframe = Frame(root)
rightframe.pack(side=RIGHT)
label = Label(frame, text = "Hello world")
label.pack()
button1 = Button(leftframe, text = "Button1")
button1.pack(padx = 3, pady = 3)
button2 = Button(rightframe, text = "Button2")
button2.pack(padx = 3, pady = 3)
button3 = Button(leftframe, text = "Button3")
button3.pack(padx = 3, pady = 3)
root.title("Test")
root.mainloop()
The Python Tkinter Button is a standard Tkinter widget. A button is used as a way for the user to interact with the User interface. Once the button is clicked, an action is triggered by the program.
from tkinter import *
def set():
print("Hello World")
root = Tk()
root.geometry("200x150")
frame = Frame(root)
frame.pack()
button = Button(frame, text = "Button1", command = set,
fg = "red", font = "Verdana 14 underline",
bd = 2, bg = "light blue", relief = "groove")
button.pack(pady = 5)
root.mainloop()
A standard Tkinter widget used to take input from the user through the user interface. A simple box is provided where the user can input text.
from tkinter import *
root = Tk()
root.geometry("200x150")
frame = Frame(root)
frame.pack()
my_entry = Entry(frame, width = 20)
my_entry.insert(0,'Username')
my_entry.pack(padx = 5, pady = 5)
my_entry2 = Entry(frame, width = 15)
my_entry2.insert(0,'password')
my_entry2.pack(padx = 5, pady = 5)
root.mainloop()
A Tkinter widget used to display simple lines of text on a GUI. Also very versatile, and can even be used to display images.
from tkinter import *
root = Tk()
root.geometry("200x150")
frame = Frame(root)
frame.pack()
var = StringVar()
var.set("Hello World")
label = Label(frame, textvariable = var )
label.pack()
root.mainloop()