Python Tkinter Check Button Introduction

Python Tkinter Check Button

The Checkbutton widget is a standard Tkinter widgets used to implement on-off selections. Checkbuttons can contain text or images, and you can associate a Python function or method with each button

The Checkbutton widget is used to display a number of options to a user as toggle buttons. The user can then select one or more options by clicking the button corresponding to each option.


 w = checkbutton(master, options)  

Example 1: Simple Button

Output: Before cheking

Output: After cheking

Example 2:

Output: Before Check

Output: After Check

Example 3: Check Box Event

Output: Before Chek

Before cheking the box it won't show any thing on your Consol window, as you can see in below output.

Output: After Chek

Here, if you check only male then it will print "male: 1, and female: 0" . If you chek only female then it will print "male: 0, and female: 1". and in case if you check both then it will print "male:1, and female: 1". after all if you will click on "Quit" it will take you out of the loop and print ">>>" as shown below.