Python Tkinter Checkbutton Widget (original) (raw)

Last Updated : 12 Jul, 2025

The Checkbutton widget is a standard Tkinter widget that is used to implement on/off selections. Checkbuttons can contain text or images. When the button is pressed, Tkinter calls that function or method.

**Note: For more reference, you can read our article,

  1. What is Widgets
  2. Python Tkinter Overview
  3. Python Tkinter Tutorial

Tkinter Checkbutton Widget Syntax

The syntax to use the checkbutton is given below.

**Syntax: Checkbutton ( master, options)
**Parameters:

Tkinter Checkbutton Options

The following are commonly used Options that can be used with this widget:

**Methods

Methods used in this widgets are as follows:

Checkbutton with Toggle Functionality

In this example, below code sets up a Tkinter window with a checkbutton labeled "Enable Feature". When clicked, it prints whether the button is selected or deselected. It customizes the appearance of the checkbutton and adds a bitmap image to it. Finally, the checkbutton is displayed in the window and flashes briefly.

Python3 `

import tkinter as tk

def on_button_toggle(): if var.get() == 1: print("Checkbutton is selected") else: print("Checkbutton is deselected")

root = tk.Tk()

Creating a Checkbutton

var = tk.IntVar() checkbutton = tk.Checkbutton(root, text="Enable Feature", variable=var, onvalue=1, offvalue=0, command=on_button_toggle)

Setting options for the Checkbutton

checkbutton.config(bg="lightgrey", fg="blue", font=("Arial", 12), selectcolor="green", relief="raised", padx=10, pady=5)

Adding a bitmap to the Checkbutton

checkbutton.config(bitmap="info", width=20, height=2)

Placing the Checkbutton in the window

checkbutton.pack(padx=40, pady=40)

Calling methods on the Checkbutton

checkbutton.flash()

root.mainloop()

`

**Output

ko

Python Tkinter - Checkbutton Widget

Multiple Checkbuttons for Selection

In this example, below code creates a Tkinter window with three checkbuttons labeled "Tutorial", "Student", and "Courses". Each button toggles between selected and deselected states. The window size is set to 300x200 pixels, and each button has a size of 2x10 units.

Python3 `

from tkinter import *

root = Tk() root.geometry("300x200")

w = Label(root, text ='GeeksForGeeks', font = "50") w.pack()

Checkbutton1 = IntVar() Checkbutton2 = IntVar() Checkbutton3 = IntVar()

Button1 = Checkbutton(root, text = "Tutorial", variable = Checkbutton1, onvalue = 1, offvalue = 0, height = 2, width = 10)

Button2 = Checkbutton(root, text = "Student", variable = Checkbutton2, onvalue = 1, offvalue = 0, height = 2, width = 10)

Button3 = Checkbutton(root, text = "Courses", variable = Checkbutton3, onvalue = 1, offvalue = 0, height = 2, width = 10)

Button1.pack() Button2.pack() Button3.pack()

mainloop()

`

**Output