CheckButton

A classic checkbox. For a checkbox that follows the active theme, prefer TCheckButton; reach for CheckButton only when you want the classic Tk look or a classic-only option such as selectColor or background.

Bind it to a BoolVar to read and control whether it's checked.

Example

const on = new BoolVar();
on.value = true; // start checked

const c = app.CheckButton({ text: 'Enable sync', variable: on });
c.pack.configure({ padx: 16, pady: 8 });

console.log(on.value); // true / false as the user toggles it

Options

Option Type Description
text string The label beside the box.
variable BoolVar Holds the checked state.
onClick function Called when the box is toggled.
onValue / offValue any Values written to variable when checked / unchecked (default 1 / 0).
state string 'normal', 'active', or 'disabled'.
image Photo Optional image.
selectColor string Colour of the indicator when checked.
background / foreground string Box and label colours.
relief string Border style: 'flat', 'raised', 'sunken', …
textVariable StringVar Bind the label text.

Methods

Method Description
invoke() Toggle the checkbox programmatically (runs onClick).

Plus the inherited widget methods — see Widget basics.

See also