wx.CheckBox

Inheritance diagram for wx.CheckBox:



Description

A checkbox is a labelled box which by default is either on (checkmark is visible) or off (no checkmark). Optionally (when the wx.CHK_3STATE style flag is set) it can have a third state, called the mixed or undetermined state. Often this is used as a “Does Not Apply” state.

Window Styles

Window Style Description
wx.CHK_2STATE Create a 2-state checkbox. This is the default.
wx.CHK_3STATE Create a 3-state checkbox. Not implemented in wxMGL, wxOS2 and wxGTK built against GTK+ 1.2.
wx.CHK_ALLOW_3RD_STATE_FOR_USER By default a user can’t set a 3-state checkbox to the third state. It can only be done from code. Using this flags allows the user to set the checkbox to the third state by clicking.
wx.ALIGN_RIGHT Makes the text appear on the left of the checkbox.

Event Handling

Event Name Description
wx.EVT_CHECKBOX(id, func) Process a wx.wxEVT_COMMAND_CHECKBOX_CLICKED event, when the checkbox is clicked.

Control Appearance


wxMSW

wxMSW

wxMAC

wxMAC

wxGTK

wxGTK


Properties Summary

Class API

Methods

__init__(parent, id=-1, label="", pos=wx.DefaultPosition, size=wx.DefaultSize, style=0, validator=wx.DefaultValidator, name=wx.CheckBoxNameStr)

Creates and shows a wx.CheckBox control.

Parameters:


Returns:

wx.CheckBox


Get3StateValue()

Gets the state of a 3-state checkbox.


Returns:

int


GetValue()

Gets the state of a 2-state checkbox.


Returns:

bool


Is3State()

Returns whether or not the checkbox is a 3-state checkbox.


Returns:

bool


Is3rdStateAllowedForUser()

Returns whether or not the user can set the checkbox to the third state.


Returns:

bool


IsChecked()

This is just a maybe more readable synonym for GetValue: just as the latter, it returns True if the checkbox is checked and False otherwise.


Returns:

bool


Set3StateValue(state)

Sets the CheckBox to the given state. The state parameter can be one of the following:

  • wx.CHK_UNCHECKED (Check is off),
  • wx.CHK_CHECKED (the Check is on)
  • wx.CHK_UNDETERMINED (Check is mixed).

Raises an exception when the CheckBox is a 2-state checkbox and setting the state to wx.CHK_UNDETERMINED.

Parameters:

  • state (int)

SetValue(state)

Sets the checkbox to the given state. This does not cause a wx.wxEVT_COMMAND_CHECKBOX_CLICKED event to get emitted.

Parameters:

  • state (bool): If True, the check is on, otherwise it is off.

Properties

ThreeStateValue
See Get3StateValue and Set3StateValue
Value
See GetValue and SetValue