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: Anywhere the user needs to provide a single-line string, not confined to a known choice, such as a name, address, password, etc. Use a separate label widget to identify the entry if needed.
Tcl usage: ttk::entry .e -textvariable name
Ruby usage: $name = ( initialValue ); {textvariable $name}
Reference: (at

Common Options

textvariable A variable linked to the entry; when the variable is changed, the entry will be updated, while when the user changes the entry, the variable will be updated.
show Show the given character instead of each letter in the actual entry; e.g. set to "*" for a password field.
width The number of characters wide the entry widget is onscreen; this does not constrain the number of characters the entry can actually hold (see validation).

How do I...

Get the current value? Look at the linked variable, or use the "get" method.
Change the current value? Change the linked variable.
You can also use the "delete first ?last?" and "insert first text" methods. Both "first" and "last" are 0-based indices indicating character position (use "end" for last), while "text" is the new text to insert.
Disable the entry? Use the "state disabled" method.
You can reenable this with "state !disabled".
Check with "instate disabled" (returns 1 if disabled, else 0).
Validate the entry? TODO.