The Wayback Machine - http://web.archive.org/web/20211117212146/https://www.geeksforgeeks.org/python-tkinter-checkbutton-widget/amp/

Python Tkinter – Checkbutton Widget

Python offers multiple options for developing a GUI (Graphical User Interface). Out of all the GUI methods, Tkinter is the most commonly used method. It is a standard Python interface to the Tk GUI toolkit shipped with Python. Python with Tkinter is the fastest and easiest way to create GUI applications. Creating a GUI using Tkinter is an easy task.

Note: For more information, refer to Python GUI – tkinter

 Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.  

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning - Basic Level Course

Checkbutton Widget

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.



Syntax:
The syntax to use the checkbutton is given below.

w = Checkbutton ( master, options)

Parameters:

Options:
Following are commonly used Option can be used with this widget :-

Methods:
Methods used in this widgets are as follows:

Example:




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:




Article Tags :