wxPython Major Classes-wxPython CheckBox Class - wxPython

What is the use of wxPython CheckBox Class?

A checkbox displays a small labeled rectangular box. When clicked, a checkmark will apppear inside the rectangle to indicate that a choice is made. Checkboxes are preferred over radio buttons when the user is to be allowed to make more than one choice. In this case, the third state is called mixed or undetermined state, generally used in ‘doesn’t apply’ scenario.

Normally, a checkbox object has two states (checked or unchecked). Tristate checkbox can also be constructed if the appropriate style parameter is given.

wx.CheckBox class constructor takes the following parameters

The following style parameter values can be used


Parameters & Description



Creates two state checkbox. Default



Creates three state checkbox



Puts a box label to the left of the checkbox

This class has two important methods − GetState() returns true or false depending on if the checkbox is checked or not. SetValue() is used to select a checkbox programmatically.

wx.EVT_CHECKBOX is the only event binder available. Associated event handler will be invoked every time any checkbox on the frame is checked or unchecked.


Following is a simple example demonstrating the use of three checkboxes. Handler function OnChecked() identifies the checkbox, which is responsible for the event and displays its state.

The complete code is

The above code produces the following output


Value A is clicked True

Value B is clicked True

Value C is clicked True

Value B is clicked False

All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

wxPython Topics