Modern Tkinter ebook If you've found the material on this site useful, please consider purchasing this e-book (only $10), which is based on the Python material in the tutorial. Doing so helps me maintain and update this site. Thank you very much!



Kindle Buy now for your Kindle
Kindle apps are also available for most smartphones, tablets, and desktops. Payment and download handled by Amazon's Kindle Store.


PDF Buy the DRM-free PDF
Downloads handled by Payment handled via Stripe (credit cards) or PayPal.

The widget roundup provides you with a quick and easy reference to the most important features and options for each Tk widget.


Widget Essentials

When to use: To allow the user to choose between two mutually exclusive choices.
Tcl usage: ttk::checkbutton .cb -text "Self-destruct on close" 
   -variable destructFlag
Ruby usage: $destructFlag = ( initialValue ); { 
   text "Self-destruct on close"; variable $destructFlag}
Reference: (at

Common Options

text The text label to be shown next to the checkbox.
variable A variable linked to the checkbutton; when the variable is changed, the checkbutton will reflect the new value, while if the user toggles the checkbutton, the variable's value will be updated.
Values reflecting the checked (default 1) and unchecked (default 0), which are held in the linked variable. If the variable contains neither of these values, the checkbutton is put into an indeterminate state, which usually implies that the choice has not yet been made (and that a default choice is inappropriate).

How do I...

See if the checkbutton is checked? Look at the linked variable.
Check or uncheck it? Change the linked variable to either the onvalue or offvalue.
See if it's in the indeterminate state? Check if the variable holds a value other than the onvalue and offvalue.
You can also use the "instate alternate" method.
Disable the checkbutton? Use the "state disabled" method.
You can reenable this with "state !disabled".
Check with "instate disabled" (returns 1 if disabled, else 0).

Less Common Options

textvariable As an alternative to text, get the string from a variable, updating when the variable changes.
command The script to invoke when the checkbutton is pressed.
Specify a Tk Image object (not the path to an image file) instead of the text label. If compound is center, top, bottom, left, or right, display the text and the image.