The Tkinter Checkbutton Class
- Checkbutton(master=None, **options) (class) [#]
A toggle button.
- Parent widget.
- Widget options. See the description of the config method for a list of available options.
- config(**options) [#]
Modifies one or more widget options. If no options are given, the method returns a dictionary containing all current option values.
- Widget options.
- The background color to use when the button is activated. Default value is system specific. (the database name is activeBackground, the class is Foreground)
- The foreground color to use when the button is activated. Default value is system specific. (activeForeground/Background)
- Controls where in the button the text (or image) should be located. Use one of N, NE, E, SE, S, SW, W, NW, or CENTER. Default is CENTER. If you change this, it is probably a good idea to add some padding as well, using the padx and/or pady options. (anchor/Anchor)
- The button background color. The default is system specific. (background/Background)
- Same as background.
The bitmap to display in the widget. If the
image option is given, this option is ignored.
You can either use a built-in bitmap, or load a bitmap from an XBM file. To load the bitmap from file, just prefix the filename with an at-sign (for example “@sample.xbm”). (bitmap/Bitmap)
- The width of the button border. The default is system specific, but is usually one or two pixels. (borderWidth/BorderWidth)
- Same as borderwidth.
- A function or method that is called when the button is pressed. The callback can be a function, bound method, or any other callable Python object. No default. (command/Command)
- Default is NONE. (compound/Compound)
- The cursor to show when the mouse pointer is moved over the button. (cursor/Cursor)
- The color to use when the button is disabled. The background is shown in the background color. (disabledForeground/DisabledForeground)
- The font to use in the button. The button can only contain text in a single font. The default is system specific. (font/Font)
- The button foreground color. The default is system specific. (foreground/Foreground)
- Same as foreground.
- The size of the button. If the button displays text, the size is given in text units. If the button displays an image, the size is given in pixels (or screen units). If the size is omitted, it is calculated based on the button contents. (height/Height)
- Default value is system specific. (highlightBackground/HighlightBackground)
- Default value is system specific. (highlightColor/HighlightColor)
- Default value is 1. (highlightThickness/HighlightThickness)
- The image to display in the widget. If specified, this takes precedence over the text and bitmap options. No default. (image/Image)
Controls if the indicator should be drawn
or not. This is on by default.
Setting this option to false means that the relief will be used as the indicator. If the button is selected, it is drawn as SUNKEN instead of RAISED. (indicatorOn/IndicatorOn)
- Defines how to align multiple lines of text. Use LEFT, RIGHT, or CENTER (default). (justify/Justify)
- Default is raised. (offRelief/OffRelief)
- The value corresponding to a non-checked button. The default is 0. (offValue/Value)
- The value corresponding to a checked button. The default is 1. (onValue/Value)
- No default value. (overRelief/OverRelief)
- Button padding. Default value is 1. (padX/Pad)
- Button padding. Default value is 1. (padY/Pad)
- Border decoration. This is usually FLAT for checkbuttons, unless they use the border as indicator (via the indicatoron option). (relief/Relief)
- Color to use for the selector. Default value is system specific. (selectColor/Background)
- Graphic image to use for the selector. No default. (selectImage/SelectImage)
- Button state. One of NORMAL, ACTIVE or DISABLED. Default is NORMAL. (state/State)
- Indicates that the user can use the Tab key to move to this button. Default is an empty string, which means that the button accepts focus only if it has any keyboard bindings (default is on, in other words). (takeFocus/TakeFocus)
- The text to display in the button. The text can contain newlines. If the bitmap or image options are used, this option is ignored. (text/Text)
Associates a Tkinter variable (usually a
StringVar) with the button. If the variable is changed,
the button text is updated.
Also see the variable option. (textVariable/Variable)
- Which character to underline, if any. Default value is -1 (no underline). (underline/Underline)
- Associates a Tkinter variable to the button. When the button is pressed, the variable is toggled between offvalue and onvalue. Explicit changes to the variable are automatically reflected by the buttons. (variable/Variable)
- The size of the button. See height for details. (width/Width)
- Determines when a button’s text should be wrapped into multiple lines. This is given in screen units. Default is no wrapping. (wrapLength/WrapLength)
- deselect() [#]
Deselects the checkbox; that is, sets the value to offvalue.
- flash() [#]
Redraws the button several times, alternating between active and normal appearance.
- invoke() [#]
Calls the command associated with the button.
- select() [#]
Selects the button; that is, sets the value to onvalue.
- toggle() [#]
Toggles the button.