Tkinter Checkbutton Options

Tkinter Checkbutton Options

In this tutorial, you shall learn about the options of a Checkbutton widget, and what each option does to the Checkbutton.

To create a Checkbutton, all we need to pass to the Checkbutton() is the master widget. But, it just displays a bare button without any text or much functionality. We can make this Checkbutton usable, or style it to the requirements of our application using options of the Checkbox().

The following table presents all the options of the Checkbox widget.

OptionDescription
1activebackgroundThe background color when the Checkbutton is active.
2activeforegroundThe foreground (text) color of the Checkbutton when the Checkbutton is active.
3bgThe background color of Checkbutton.
4bitmapIt displays an image (monochrome) on the Checkbutton.
5bdThe size of the border around the Checkbutton.
6commandA callback function to be called when the state of the Checkbutton is changed.
7cursorThe cursor to be displayed when mouse is over the the Checkbutton.
8disableforegroundThe foreground (text) color of the Checkbutton when the Checkbutton is disabled.
9fontThe font used for the text of Checkbutton.
10fgThe foreground color used for the text of the Checkbutton.
11heightHeight of the checkbutton in number of lines.
12highlightcolorThe color of the focus highlight when the Checkbutton get focus.
13imageThe image is displayed on the Checkbutton.
14justifyThe alignment of the text when in Checkbutton.
15offvalueThe value to be set when the Checkbutton is unchecked. Default value is 0.
16onvalueThe value to be set when the Checkbutton is checked. Default value is 1.
17padxThe padding along X-axis (horizontal) of the Checkbutton.
18padyThe padding along Y-axis (vertical) of the Checkbutton.
19reliefType of the border for the Checkbutton. Default value is FLAT.
20selectcolorColor of the checkbutton when it is selected/checked.
21selectimageImage to be displayed for the checkbutton when it is selected/checked.
22stateThe state of the Checkbutton. Default value is normal. You may display the Checkbutton by setting this state to DISABLED.
24underlineIndex of the character in the text of Checkbutton, which is to be underlined.
25variableVariable associated with the Checkbutton that tracks whether it is checked or not.
26widthWidth of the Checkbutton in the units of number of characters.
27wraplengthNumber of characters to be allowed in a single line, when there is longer text that takes more than one line.

Summary

In this Python Tkinter tutorial, we have seen the options of a Checkbutton widget.

Code copied to clipboard successfully 👍