Python Tkinter Checkbutton
In GUI applications, collecting user input is an important part of creating interactive interfaces. Python’s standard GUI toolkit, Tkinter, provides several widgets for handling user interactions, and the Checkbutton is one of the most useful options when users need to make multiple selections.
A Checkbutton works like an on/off switch, allowing users to check or uncheck individual choices. It is commonly useful in forms, settings screens, and applications where users need to select their preferences.
Table of Contents

Complete Advance AI Topics: Click Here
SQL Tutorial: Click Here
What is a Tkinter Checkbutton?
A Checkbutton is a Tkinter widget that allows users to select multiple choices from a list of available options. Each Checkbutton can be switched between a selected and unselected state, making it suitable for applications that require multiple-choice input.
The Checkbutton is also flexible because it can display both text and images, allowing developers to customize the appearance of their graphical interfaces.
Syntax of Checkbutton
w = Checkbutton(master, options)
Here, master represents the parent widget, such as a Tkinter window or frame. The options parameter contains the different configuration attributes used to customize the Checkbutton.
Tkinter Checkbutton Options
The following table lists the commonly available configuration options for the Checkbutton widget:
| SN | Option | Description |
|---|---|---|
| 1 | activebackground | Sets the background color when the Checkbutton is hovered. |
| 2 | activeforeground | Sets the foreground or text color when the Checkbutton is hovered. |
| 3 | bg | Defines the background color of the Checkbutton. |
| 4 | bitmap | Displays a monochrome image on the Checkbutton. |
| 5 | bd | Specifies the border size of the Checkbutton. |
| 6 | command | Associates a function that runs when the Checkbutton state changes. |
| 7 | cursor | Changes the mouse cursor when it moves over the Checkbutton. |
| 8 | disableforeground | Defines the text color when the Checkbutton is disabled. |
| 9 | font | Sets the font style of the Checkbutton. |
| 10 | fg | Sets the foreground or text color of the Checkbutton. |
| 11 | height | Specifies the height of the Checkbutton. The default value is 1. |
| 12 | highlightcolor | Sets the color of the focus highlight when the Checkbutton is selected. |
| 13 | image | Displays an image on the Checkbutton. |
| 14 | justify | Controls text alignment when multiline text is used. |
| 15 | offvalue | Specifies the value assigned when the Checkbutton is unchecked. The default is 0. |
| 16 | onvalue | Specifies the value assigned when the Checkbutton is checked. The default is 1. |
| 17 | padx | Sets the horizontal padding inside the Checkbutton. |
| 18 | pady | Sets the vertical padding inside the Checkbutton. |
| 19 | relief | Defines the border style of the Checkbutton. The default is FLAT. |
| 20 | selectcolor | Sets the color of the Checkbutton when it is selected. The default is red. |
| 21 | selectimage | Displays a different image when the Checkbutton is selected. |
| 22 | state | Defines the state of the Checkbutton, such as NORMAL, DISABLED, or ACTIVE. |
| 23 | underline | Underlines a specific character in the Checkbutton label. |
| 24 | variable | Connects the Checkbutton to a Tkinter variable. |
| 25 | width | Specifies the width of the Checkbutton in characters. |
| 26 | wraplength | Wraps the Checkbutton text across multiple lines at a specified width. |
Tkinter Checkbutton Methods
Tkinter provides several methods that can be used to control and interact with a Checkbutton programmatically. Some commonly used methods are:
| SN | Method | Description |
|---|---|---|
| 1 | deselect() | Unchecks the Checkbutton. |
| 2 | flash() | Flashes the Checkbutton between its active and normal colors. |
| 3 | invoke() | Calls the function associated with the Checkbutton. |
| 4 | select() | Checks the Checkbutton. |
| 5 | toggle() | Switches the Checkbutton between checked and unchecked states. |
Example: Creating Checkbuttons in Tkinter
The following example creates multiple Checkbuttons in a Tkinter window. Users can select their preferred programming languages by checking the available options.
from tkinter import *
# Create main window
top = Tk()
top.geometry("250x200")
title_label = Label(
top,
text="Select Your Preferred Languages:",
font=("Arial", 10, "bold")
)
title_label.pack()
# Define Tkinter variables
checkvar1 = IntVar()
checkvar2 = IntVar()
checkvar3 = IntVar()
# Creating Checkbuttons
chkbtn1 = Checkbutton(
top,
text="Python",
variable=checkvar1,
onvalue=1,
offvalue=0,
height=2,
width=10
)
chkbtn2 = Checkbutton(
top,
text="Java",
variable=checkvar2,
onvalue=1,
offvalue=0,
height=2,
width=10
)
chkbtn3 = Checkbutton(
top,
text="C++",
variable=checkvar3,
onvalue=1,
offvalue=0,
height=2,
width=10
)
chkbtn1.pack()
chkbtn2.pack()
chkbtn3.pack()
# Run main event loop
top.mainloop()
Output:
The program creates a simple GUI containing three Checkbuttons labeled Python, Java, and C++. Users can select one or more of these options according to their preferences.
Download New Real Time Projects :- Click here
Conclusion
The Checkbutton is an important Tkinter widget for handling multiple selections in Python GUI applications. With its different configuration options and useful methods, developers can customize its appearance and behavior according to the application’s requirements.
Whether you are building forms, settings pages, or preference-based interfaces, the Checkbutton provides a simple and effective way to collect user input.
For more Python GUI tutorials and advanced Tkinter projects, stay tuned to UpdateGadh!
SEO Keywords
python tkinter checkbutton example
python tkinter checkbutton get value
python tkinter checkbutton tutorial
tkinter checkbutton set value
tkinter checkbutton command
tkinter checkbutton state
tkinter checkbutton select
tkinter checkbutton default value
python tkinter checkbutton
python tkinter checkbutton default checked
python tkinter checkbutton get value
python tkinter checkbutton example
python tkinter checkbutton command
python tkinter checkbutton size
python tkinter checkbutton disable