Skip to content

CheckBox

Create a checkbox the user can check and uncheck.

Creating a CheckBox

You can create a CheckBox using the following functions:

CheckBox()
CheckBox(text, action, color, textColor, font, rotation, visibility)
Parameter Type Default Description
text str '' The text shown beside the checkbox.
action function None The function to call when the checkbox changes; it receives one parameter, True if it was just checked or False if it was just unchecked.
color Color Color.CLEAR The color behind the box and its text.
textColor Color Color.BLACK The text color.
font Font None The font, for example Font("Serif", Font.ITALIC, 16). If omitted, the default font (Arial, size 13) is used.
rotation int or float 0 How far to turn the checkbox, in degrees, counter-clockwise.
visibility int 100 How visible the checkbox is, from 0 (invisible) to 100 (fully visible).

For example,

checkbox = CheckBox("Check Me Out!")

Once created, you can add it to a Display using the Display's add() function.

Functions

Once a CheckBox has been created, the following functions are available:

Function Description
getText() Return the checkbox's text.
setText(text) Set the checkbox's text.
getColor() Return the checkbox's background color.
setColor(color) Set the checkbox's background color.
getTextColor() Return the checkbox's text color.
setTextColor(color) Set the checkbox's text color.
getFont() Return the checkbox's font.
setFont(font) Set the checkbox's font.
check() Check the checkbox.
uncheck() Uncheck the checkbox.
isChecked() Report whether the checkbox is checked.

Additionally, the following common functions are available: