beetlebug▾
/

checkbutton

Makes a checkbutton: a button with an indicator that the user turns on and off.

checkbutton PATHNAME ?OPTION VALUE ...?

Description

Makes a checkbutton widget with the name PATHNAME and the options of the call, and makes the command PATHNAME for the widget commands below. A click on the checkbutton changes its state between on and off. It then sets its -variable to -onvalue or -offvalue, and runs its -command.

The variable and the checkbutton stay equal: a script that sets the variable to -onvalue selects the checkbutton. A value that is neither -onvalue nor -offvalue shows the checkbutton as off, and the value of -tristatevalue shows the tristate.

The parent of PATHNAME must exist, and PATHNAME must not. A checkbutton is a Checkbutton in CSS and for the option database, and ztk::class gives it a style class for a stylesheet. The style class switch draws the indicator as a track with a knob.

The theme draws the border, the padding, and the indicator, so -borderwidth, -padx, and -pady default to 0, and a value of the script overrides the theme.

Widget commands

CommandDescription
checkbutton deselectTurns the checkbutton off.
checkbutton flashFlashes the checkbutton between its active and normal colors.
checkbutton invokeChanges the state of the checkbutton and runs its command, as a click does.
checkbutton selectTurns the checkbutton on.
checkbutton toggleTurns the checkbutton on when it is off, and off when it is on.
checkbutton cgetGives the value of an option of the checkbutton.
checkbutton configureGives or sets the options of the checkbutton.

Options

OptionTypeDefaultDatabase nameDescription
-activebackgroundcolor#ecececactiveBackgroundThe background color of the active state, in the look of Tk on X11.
-activeforegroundcolor#000000activeForegroundThe text color of the active state, in the look of Tk on X11.
-anchoranchorcenteranchorThe place of the content in a checkbutton larger than it.
-backgroundcolor#d9d9d9backgroundThe background color of the checkbutton.
-bitmapbitmap nameemptybitmapA bitmap name of Tk to show in place of the text.
-borderwidthscreen distance0borderWidthThe width of the border of the checkbutton.
-commandscriptemptycommandA script that runs when the user clicks the checkbutton.
-compoundcompoundnonecompoundShows the image and the text together, with the image at that side.
-cursorcursor nameemptycursorThe shape of the pointer over the checkbutton.
-disabledforegroundcolor#a3a3a3disabledForegroundThe text color while the state is disabled.
-fontfontTkDefaultFontfontThe font of the text.
-foregroundcolor#000000foregroundThe color of the text.
-heightinteger0heightThe height of the checkbutton in lines of text, or in pixels for an image.
-highlightbackgroundcolor#d9d9d9highlightBackgroundThe color of the focus ring while the checkbutton has no focus, in the look of Tk on X11.
-highlightcolorcolor#000000highlightColorThe color of the focus ring while the checkbutton has the focus, in the look of Tk on X11.
-highlightthicknessscreen distance1highlightThicknessThe width of the focus ring, in the look of Tk on X11.
-imagestringemptyimageAn image to show in place of the text.
-indicatoronboolean1indicatorOnWhether the checkbutton draws its indicator.
-justifyjustificationcenterjustifyThe alignment of the lines of the text.
-offreliefreliefraisedoffReliefThe relief of the checkbutton with no indicator while it is not selected.
-offvaluestring0offValueThe value of the variable while the checkbutton is not selected.
-onvaluestring1onValueThe value of the variable while the checkbutton is selected.
-overreliefreliefemptyoverReliefThe relief of the checkbutton while the pointer is over it.
-padxscreen distance0padXThe space at the left and the right of the content.
-padyscreen distance0padYThe space above and below the content.
-reliefreliefflatreliefThe 3-D look of the border.
-selectcolorcolor#ffffffselectColorThe background color of the indicator while the checkbutton is selected.
-selectimagestringemptyselectImageThe image to show while the checkbutton is selected.
-statestatenormalstateThe state of the checkbutton: normal, active, or disabled.
-takefocusstringemptytakeFocusWhether the Tab key can move the focus to the checkbutton.
-textstringemptytextThe text of the checkbutton.
-textvariablevariable nameemptytextVariableA global variable whose value is the text of the checkbutton.
-tristateimagestringemptytristateImageThe image to show in the tristate.
-tristatevaluestringemptytristateValueThe value of the variable that puts the checkbutton in the tristate.
-underlineinteger-1underlineThe index of a character of the text to underline, for a keyboard shortcut.
-variablevariable nameemptyvariableThe global variable that holds the value of the checkbutton.
-widthinteger0widthThe width of the checkbutton in characters of the font, or in pixels for an image.
-wraplengthscreen distance0wrapLengthThe longest line of the text before it breaks into a new line.

-activebackground COLOR

The background color of the active state, in the look of Tk on X11.

The background of the checkbutton while the pointer is over it or its state is active. A color is a name such as red, or #RGB, #RRGGBB, or #RRRRGGGGBBBB.

checkbutton with -text Agree -variable ::ref::off -state active and -activebackground {#ececec}-activebackground {#ececec}checkbutton with -text Agree -variable ::ref::off -state active and -activebackground {#fde68a}-activebackground {#fde68a}
Each with -text Agree -variable ::ref::off -state active.
% checkbutton .activebackground -activebackground {#336699}
> .activebackground cget -activebackground
#336699
% checkbutton .activebackground2 -activebackground nocolor
unknown color name "nocolor"
-errorcode TK LOOKUP COLOR nocolor

-activeforeground COLOR

The text color of the active state, in the look of Tk on X11.

The color of the text while the pointer is over the checkbutton or its state is active.

checkbutton with -text Agree -variable ::ref::off -state active and -activeforeground {#888888}-activeforeground {#888888}checkbutton with -text Agree -variable ::ref::off -state active and -activeforeground {#b91c1c}-activeforeground {#b91c1c}
Each with -text Agree -variable ::ref::off -state active.
% checkbutton .activeforeground -activeforeground {#336699}
> .activeforeground cget -activeforeground
#336699
% checkbutton .activeforeground2 -activeforeground nocolor
unknown color name "nocolor"
-errorcode TK LOOKUP COLOR nocolor

-anchor ANCHOR

The place of the content in a checkbutton larger than it.

When the checkbutton is larger than its text or image, the anchor puts the content at that side or corner. center puts it in the middle.

Values: n, ne, e, se, s, sw, w, nw, center.

checkbutton with -text Agree -variable ::ref::off -width 14 and -anchor w-anchor wcheckbutton with -text Agree -variable ::ref::off -width 14 and -anchor center-anchor centercheckbutton with -text Agree -variable ::ref::off -width 14 and -anchor e-anchor e
Each with -text Agree -variable ::ref::off -width 14.
% checkbutton .anchor -anchor w
> .anchor cget -anchor
w
% checkbutton .anchor2 -anchor middle
bad anchor "middle": must be n, ne, e, se, s, sw, w, nw, or center
-errorcode TCL LOOKUP INDEX anchor middle

-background COLOR

The background color of the checkbutton.

The color behind the content. -bg is the same option. A color is a name such as red, or #RGB, #RRGGBB, or #RRRRGGGGBBBB.

checkbutton with -text Agree -variable ::ref::off and -background {#fde68a}-background {#fde68a}checkbutton with -text Agree -variable ::ref::off and -background {#bfdbfe}-background {#bfdbfe}
Each with -text Agree -variable ::ref::off.
% checkbutton .background -background {#336699}
> .background cget -background
#336699
% checkbutton .background2 -background nocolor
unknown color name "nocolor"
-errorcode TK LOOKUP COLOR nocolor

-bitmap BITMAP

A bitmap name of Tk to show in place of the text.

The name of a built-in bitmap of Tk, such as error, info, or question. A value that starts with @ names a file. ztk stores the value for cget and shows no bitmap.

% checkbutton .bitmap -bitmap error
> .bitmap cget -bitmap
error
% checkbutton .bitmap2 -bitmap nobitmap
bitmap "nobitmap" not defined
-errorcode TK LOOKUP BITMAP nobitmap

-borderwidth DISTANCE

The width of the border of the checkbutton.

The width of the border around the checkbutton. -bd is the same option. The default 0 leaves the border to the theme, and a value of the script replaces it. A distance is a count of pixels, or a number with c, i, m, or p for centimeters, inches, millimeters, or points.

checkbutton with -text Agree -variable ::ref::off -relief solid and -borderwidth 0-borderwidth 0checkbutton with -text Agree -variable ::ref::off -relief solid and -borderwidth 1-borderwidth 1checkbutton with -text Agree -variable ::ref::off -relief solid and -borderwidth 4-borderwidth 4
Each with -text Agree -variable ::ref::off -relief solid.
% checkbutton .borderwidth -borderwidth 4
> .borderwidth cget -borderwidth
4
% checkbutton .borderwidth2 -borderwidth x
bad screen distance "x"
-errorcode TK VALUE PIXELS

-command SCRIPT

A script that runs when the user clicks the checkbutton.

The script runs at the global level after the checkbutton changes its variable. invoke runs it too.

% checkbutton .command -command {set ::done 1}
> .command cget -command
set ::done 1

ztk stores each script with no check. An error of the script is the error of invoke.

-compound WORD

Shows the image and the text together, with the image at that side.

With none, a checkbutton with an -image shows only the image. Each other value shows the image and the text, with the image at that side of the text, or under the text with center.

Values: bottom, center, left, none, right, top.

% checkbutton .compound -compound bottom
> .compound cget -compound
bottom
% checkbutton .compound2 -compound bogus
bad compound "bogus": must be bottom, center, left, none, right, or top
-errorcode TCL LOOKUP INDEX compound bogus

-cursor CURSOR

The shape of the pointer over the checkbutton.

A cursor name of Tk, such as hand2 or xterm. A value that starts with @ names a file. An empty value uses the cursor of the parent.

% checkbutton .cursor -cursor hand2
> .cursor cget -cursor
hand2
% checkbutton .cursor2 -cursor nocursor
bad cursor spec "nocursor"
-errorcode TK VALUE CURSOR

-disabledforeground COLOR

The text color while the state is disabled.

The color of the text while -state is disabled.

checkbutton with -text Agree -variable ::ref::off -state disabled and -disabledforeground {#888888}-disabledforeground {#888888}checkbutton with -text Agree -variable ::ref::off -state disabled and -disabledforeground {#b91c1c}-disabledforeground {#b91c1c}
Each with -text Agree -variable ::ref::off -state disabled.
% checkbutton .disabledforeground -disabledforeground {#336699}
> .disabledforeground cget -disabledforeground
#336699
% checkbutton .disabledforeground2 -disabledforeground nocolor
unknown color name "nocolor"
-errorcode TK LOOKUP COLOR nocolor

-font FONT

The font of the text.

A font name, such as TkDefaultFont, or a font description, such as {Helvetica 12 bold}. A family that does not exist falls back to a font of the system.

checkbutton with -text Agree -variable ::ref::off and -font TkDefaultFont-font TkDefaultFontcheckbutton with -text Agree -variable ::ref::off and -font TkFixedFont-font TkFixedFontcheckbutton with -text Agree -variable ::ref::off and -font {Helvetica 16 bold}-font {Helvetica 16 bold}
Each with -text Agree -variable ::ref::off.
% checkbutton .font -font {Helvetica 12 bold}
> .font cget -font
Helvetica 12 bold
% checkbutton .font2 -font {Helvetica big}
expected integer but got "big"
-errorcode TCL VALUE NUMBER

-foreground COLOR

The color of the text.

The color of the text. -fg is the same option. A color is a name such as red, or #RGB, #RRGGBB, or #RRRRGGGGBBBB.

checkbutton with -text Agree -variable ::ref::off and -foreground {#b91c1c}-foreground {#b91c1c}checkbutton with -text Agree -variable ::ref::off and -foreground {#2563eb}-foreground {#2563eb}
Each with -text Agree -variable ::ref::off.
% checkbutton .foreground -foreground {#336699}
> .foreground cget -foreground
#336699
% checkbutton .foreground2 -foreground nocolor
unknown color name "nocolor"
-errorcode TK LOOKUP COLOR nocolor

-height LINES

The height of the checkbutton in lines of text, or in pixels for an image.

For a checkbutton with text, the height in lines of the font. For a checkbutton with an image, the height in pixels. 0 makes the checkbutton as tall as its content.

checkbutton with -text Agree -variable ::ref::off and -height 0-height 0checkbutton with -text Agree -variable ::ref::off and -height 2-height 2checkbutton with -text Agree -variable ::ref::off and -height 3-height 3
Each with -text Agree -variable ::ref::off.
% checkbutton .height -height 5
> .height cget -height
5
% checkbutton .height2 -height x
expected integer but got "x"
-errorcode TCL VALUE NUMBER

-highlightbackground COLOR

The color of the focus ring while the checkbutton has no focus, in the look of Tk on X11.

The color of the highlight ring of -highlightthickness while the checkbutton does not have the focus. ztk stores the value with no effect.

% checkbutton .highlightbackground -highlightbackground {#336699}
> .highlightbackground cget -highlightbackground
#336699
% checkbutton .highlightbackground2 -highlightbackground nocolor
unknown color name "nocolor"
-errorcode TK LOOKUP COLOR nocolor

-highlightcolor COLOR

The color of the focus ring while the checkbutton has the focus, in the look of Tk on X11.

The color of the highlight ring of -highlightthickness while the checkbutton has the focus. ztk stores the value with no effect.

% checkbutton .highlightcolor -highlightcolor {#336699}
> .highlightcolor cget -highlightcolor
#336699
% checkbutton .highlightcolor2 -highlightcolor nocolor
unknown color name "nocolor"
-errorcode TK LOOKUP COLOR nocolor

-highlightthickness DISTANCE

The width of the focus ring, in the look of Tk on X11.

The width of the ring around the checkbutton that shows the focus. The modern theme draws the focus with the stylesheet.

% checkbutton .highlightthickness -highlightthickness 4
> .highlightthickness cget -highlightthickness
4
% checkbutton .highlightthickness2 -highlightthickness x
bad screen distance "x"
-errorcode TK VALUE PIXELS

-image TEXT

An image to show in place of the text.

The name of an image of image create. With an image and -compound none, the checkbutton shows the image and no text.

% checkbutton .image -image pic
> .image cget -image
pic

ztk stores each name with no check. Tk 8.6.16 gives an error for an image that does not exist.

-indicatoron BOOLEAN

Whether the checkbutton draws its indicator.

With a false value, the checkbutton draws no indicator.

checkbutton with -text Agree -variable ::ref::off and -indicatoron 1-indicatoron 1checkbutton with -text Agree -variable ::ref::off and -indicatoron 0-indicatoron 0
Each with -text Agree -variable ::ref::off.
# With no indicator, the checkbutton is narrower.
% checkbutton .indicatoron -text Bold
> checkbutton .indicatoron0 -text Bold -indicatoron 0
> expr {[winfo reqwidth .indicatoron0] < [winfo reqwidth .indicatoron]}
1
% checkbutton .indicatoron2 -indicatoron maybe
expected boolean value but got "maybe"
-errorcode TCL VALUE NUMBER

-justify SIDE

The alignment of the lines of the text.

How the lines of a text with more than one line line up with each other. A text breaks into lines at each newline and at -wraplength.

Values: left, right, center.

checkbutton with -text Short
A longer line -variable ::ref::off and -justify left-justify leftcheckbutton with -text Short
A longer line -variable ::ref::off and -justify center-justify centercheckbutton with -text Short
A longer line -variable ::ref::off and -justify right-justify right
Each with -text Short A longer line -variable ::ref::off.
% checkbutton .justify -justify left
> .justify cget -justify
left
% checkbutton .justify2 -justify middle
bad justification "middle": must be left, right, or center
-errorcode TCL LOOKUP INDEX justification middle

-offrelief RELIEF

The relief of the checkbutton with no indicator while it is not selected.

With -indicatoron 0, Tk draws a checkbutton that is not selected with this relief. ztk stores the value with no effect.

Values: flat, groove, raised, ridge, solid, sunken.

% checkbutton .offrelief -offrelief groove
> .offrelief cget -offrelief
groove
% checkbutton .offrelief2 -offrelief bumpy
bad relief "bumpy": must be flat, groove, raised, ridge, solid, or sunken
-errorcode TCL LOOKUP INDEX relief bumpy

-offvalue TEXT

The value of the variable while the checkbutton is not selected.

deselect and a click to off set the variable to this value.

% checkbutton .offvalue -offvalue no -variable reply
> .offvalue deselect
> set reply
no

Each string is a valid value.

-onvalue TEXT

The value of the variable while the checkbutton is selected.

select and a click to on set the variable to this value.

% checkbutton .onvalue -onvalue yes -variable answer
> .onvalue select
> set answer
yes

Each string is a valid value.

-overrelief RELIEF

The relief of the checkbutton while the pointer is over it.

An empty value keeps the relief of -relief. ztk stores the value with no effect.

Values: flat, groove, raised, ridge, solid, sunken.

% checkbutton .overrelief -overrelief groove
> .overrelief cget -overrelief
groove
% checkbutton .overrelief2 -overrelief bumpy
bad relief "bumpy": must be flat, groove, raised, ridge, solid, or sunken
-errorcode TCL LOOKUP INDEX relief bumpy

-padx DISTANCE

The space at the left and the right of the content.

The default 0 leaves the padding to the theme, and a value of the script replaces the padding of the theme at both sides.

checkbutton with -text Agree -variable ::ref::off and -padx 1-padx 1checkbutton with -text Agree -variable ::ref::off and -padx 4-padx 4checkbutton with -text Agree -variable ::ref::off and -padx 16-padx 16
Each with -text Agree -variable ::ref::off.
% checkbutton .padx -padx 4
> .padx cget -padx
4
% checkbutton .padx2 -padx x
bad screen distance "x"
-errorcode TK VALUE PIXELS

-pady DISTANCE

The space above and below the content.

The default 0 leaves the padding to the theme, and a value of the script replaces the padding of the theme above and below.

checkbutton with -text Agree -variable ::ref::off and -pady 1-pady 1checkbutton with -text Agree -variable ::ref::off and -pady 2-pady 2checkbutton with -text Agree -variable ::ref::off and -pady 10-pady 10
Each with -text Agree -variable ::ref::off.
% checkbutton .pady -pady 4
> .pady cget -pady
4
% checkbutton .pady2 -pady x
bad screen distance "x"
-errorcode TK VALUE PIXELS

-relief RELIEF

The 3-D look of the border.

The style of the border: raised and sunken look 3-D, and groove and ridge are lines. The theme draws the border, and the CSS of the theme can give a relief its own look with border-style.

Values: flat, groove, raised, ridge, solid, sunken.

checkbutton with -text Agree -variable ::ref::off -borderwidth 4 and -relief flat-relief flatcheckbutton with -text Agree -variable ::ref::off -borderwidth 4 and -relief raised-relief raisedcheckbutton with -text Agree -variable ::ref::off -borderwidth 4 and -relief sunken-relief sunkencheckbutton with -text Agree -variable ::ref::off -borderwidth 4 and -relief groove-relief groovecheckbutton with -text Agree -variable ::ref::off -borderwidth 4 and -relief ridge-relief ridgecheckbutton with -text Agree -variable ::ref::off -borderwidth 4 and -relief solid-relief solid
Each with -text Agree -variable ::ref::off -borderwidth 4. The modern theme draws each relief but flat with the same border.
% checkbutton .relief -relief groove
> .relief cget -relief
groove
% checkbutton .relief2 -relief bumpy
bad relief "bumpy": must be flat, groove, raised, ridge, solid, or sunken
-errorcode TCL LOOKUP INDEX relief bumpy

-selectcolor COLOR

The background color of the indicator while the checkbutton is selected.

In Tk, the fill of the indicator while the checkbutton is selected. ztk stores the value with no effect: the theme gives the color of the indicator.

% checkbutton .selectcolor -selectcolor {#336699}
> .selectcolor cget -selectcolor
#336699
% checkbutton .selectcolor2 -selectcolor nocolor
unknown color name "nocolor"
-errorcode TK LOOKUP COLOR nocolor

-selectimage TEXT

The image to show while the checkbutton is selected.

In Tk, a checkbutton with an -image shows this image in place of -image while it is selected.

% checkbutton .selectimage -selectimage pic
> .selectimage cget -selectimage
pic

ztk stores each name with no check. Tk 8.6.16 gives an error for an image that does not exist.

-state STATE

The state of the checkbutton: normal, active, or disabled.

disabled draws the text with -disabledforeground, and a click or invoke has no effect. active uses the colors of -activebackground and -activeforeground. select, deselect, and toggle change the variable in each state.

Values: active, disabled, normal.

checkbutton with -text Agree -variable ::ref::off and -state normal-state normalcheckbutton with -text Agree -variable ::ref::off and -state active-state activecheckbutton with -text Agree -variable ::ref::off and -state disabled-state disabled
Each with -text Agree -variable ::ref::off.
% checkbutton .state -state disabled
> .state cget -state
disabled
% checkbutton .state2 -state busy
bad state "busy": must be active, disabled, or normal
-errorcode TCL LOOKUP INDEX state busy

-takefocus TEXT

Whether the Tab key can move the focus to the checkbutton.

1 puts the checkbutton in the order of the Tab key, and 0 leaves it out. An empty value uses the default rule of Tk for the widget. In Tk the value can also be a script, and its result is the answer. ztk stores each value with no check.

% checkbutton .takefocus -takefocus 1
> .takefocus cget -takefocus
1

ztk stores each value of the option with no check.

-text TEXT

The text of the checkbutton.

The text that the checkbutton shows. A newline starts a new line.

checkbutton with -variable ::ref::off and -text Agree-text Agreecheckbutton with -variable ::ref::off and -text {Agree and more}-text {Agree and more}
Each with -variable ::ref::off.
% checkbutton .text -text Save
> .text cget -text
Save

Each string is a valid text.

-textvariable VAR

A global variable whose value is the text of the checkbutton.

The checkbutton shows the value of the global variable VAR, and changes its text when the variable changes. The variable stays after the checkbutton is destroyed.

% checkbutton .textvariable -textvariable v
> .textvariable cget -textvariable
v

Each name is a valid variable name.

-tristateimage TEXT

The image to show in the tristate.

With an -image, Tk shows this image while the variable has the value of -tristatevalue.

% checkbutton .tristateimage -tristateimage pic
> .tristateimage cget -tristateimage
pic

ztk stores each name with no check. Tk 8.6.16 gives an error for an image that does not exist.

-tristatevalue TEXT

The value of the variable that puts the checkbutton in the tristate.

When the variable has this value, the checkbutton shows the tristate: neither on nor off.

% checkbutton .tristatevalue -tristatevalue maybe
> .tristatevalue cget -tristatevalue
maybe

Each string is a valid value.

-underline N

The index of a character of the text to underline, for a keyboard shortcut.

The index from 0 of the character of -text to underline. -1 underlines no character.

% checkbutton .underline -underline 5
> .underline cget -underline
5
% checkbutton .underline2 -underline x
expected integer but got "x"
-errorcode TCL VALUE NUMBER

-variable VAR

The global variable that holds the value of the checkbutton.

The variable has the value of -onvalue while the checkbutton is selected, and of -offvalue while it is not. The default is a global variable with the last part of the path name, so .bold uses bold. A change of the variable changes the checkbutton. When the variable has no value, the checkbutton sets it to -offvalue.

% checkbutton .variable -variable wrap
> .variable select
> set wrap
1

# The default variable.
% checkbutton .italic
> .italic cget -variable
italic

Each name is a valid variable name.

-width CHARS

The width of the checkbutton in characters of the font, or in pixels for an image.

For a checkbutton with text, the width in average characters of the font. For a checkbutton with an image, the width in pixels. 0 makes the checkbutton as wide as its content.

checkbutton with -text Agree -variable ::ref::off and -width 0-width 0checkbutton with -text Agree -variable ::ref::off and -width 8-width 8checkbutton with -text Agree -variable ::ref::off and -width 14-width 14
Each with -text Agree -variable ::ref::off.
% checkbutton .width -width 5
> .width cget -width
5
% checkbutton .width2 -width x
expected integer but got "x"
-errorcode TCL VALUE NUMBER

-wraplength DISTANCE

The longest line of the text before it breaks into a new line.

A text longer than this distance breaks at a space into more lines. 0 breaks no line.

% checkbutton .wraplength -wraplength 4
> .wraplength cget -wraplength
4
% checkbutton .wraplength2 -wraplength x
bad screen distance "x"
-errorcode TK VALUE PIXELS

Bindings

EventDescription
<Enter>The pointer is over the button: it shows the active colors.
<Leave>The pointer leaves the button, and the active colors go.
<Button-1>A press switches the variable between -onvalue and -offvalue and runs the -command script at once, as invoke does. A press on a disabled button changes no value.
<Key-space>Switches the variable and runs the -command script, as invoke does.
<Key-Return>The same as the space key.

Virtual events

EventDescription
<<Invoke>>The same as the space key. event generate .c <<Invoke>> sends it.

Returns

PATHNAME.

Examples

# The default variable has the name of the last part of the path.
% checkbutton .bold -text Bold
> .bold invoke
> set bold
1

% checkbutton .sound -text Sound -variable sound -onvalue on -offvalue off
> set sound on
> .sound toggle
> set sound
off

% winfo class [checkbutton .go]
Checkbutton

Errors

% checkbutton .x -foo 1
unknown option "-foo"
-errorcode TK LOOKUP OPTION -foo

% checkbutton .twice
> checkbutton .twice
window name "twice" already exists in parent
-errorcode TK VALUE WINDOW EXISTS

# The parent .no does not exist.
% checkbutton .no.b
bad window path name ".no"
-errorcode TK LOOKUP WINDOW .no

% checkbutton
wrong # args: should be "checkbutton pathName ?-option value ...?"
-errorcode TCL WRONGARGS

Differences from Tcl

Facts

Capability
None.
Tcl release
Tcl 9.1 and 8.6.
Since
ztk 1.0.0-beta.1

See also