How to get state of Checkbutton when it's selected? How to get state of Checkbutton when it's selected? tkinter tkinter

How to get state of Checkbutton when it's selected?


You need to associate the Checkbox with a variable:

is_checked = IntVar()check = Checkbutton(window, text="Add both", onvalue=1, offvalue=0, variable=is_checked)

Then utilise do your check such as:

if is_checked.get():    # do something