Learn Before
Concept

Checkbutton in Tkinter

To use the checkbox we use the Checkbutton() class.

If we want to store the state of the checkbox (checked or unchecked), we can assign the state to a variable.

Syntax:

isChecked = IntVar() check1 = Checkbutton(text='some text', variable='isChecked') check1.pack()

By default, the state is 0 (unchecked) and 1 (checked). But we can change it using the onvalue and offvalue parameter:

check1 = Checkbutton(text='some text', variable='isChecked', onvalue="Selected", offvalue="NotSelected")

0

1

Updated 2021-08-17

Contributors are:

Who are from:

Tags

Python Programming Language

Data Science