Home Contact


Information you need to build high-quality Tk user interfaces.


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 SendOwl.com. Payment handled via PayPal
(click "Don't have a PayPal account" to use a credit card).

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: When you want your user to invoke some operation (submit a dialog, calculate a result, save a file, etc.)
Tcl usage: ttk::button .b -text "Okay" -command "submitForm"
Ruby usage: Tk::Tile::Button.new(parent) {text "Okay"; command "submitForm"}
Reference: (at www.tcl.tk)

Common Options

text The label to be shown in the button.
command The script to invoke when the button is pressed.
default If "active", this is a "default" button for the window, i.e. the one that will be invoked if the user presses Return. Regular state is "normal" (You need to set up the event binding separately.)
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.

How do I...

Press the button from my program? Use the "invoke" method. Useful so you don't need to repeat the button's command script in multiple places in your program.
Disable the button? Use the "state disabled" method.
You can reenable this with "state !disabled".
Check with "instate disabled" (returns 1 if disabled, else 0).