Modern Tkinter

Modern Tkinter ebook

Want TkDocs to go? If you've found the material on this site useful, please consider buying this book, which is based on the Python material in the tutorial.

Mark Roseman

p.s. your purchase helps me improve this site... thank you!


Only $10 for e-book. pick your format:

Paperback PDF Kindle Apple Books B&N Nook Kobo

(Slightly more for paperback. Also available on other e-book platforms.)

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 show a static text or image to the user, whether identifying some other user interface element (e.g. "Name" next to an entry), something purely decorative, or presenting a result. Users normally do not interact with labels.
Tcl:ttk::label .lbl -text "Name:"
Ruby:lbl = {text "Name:"}
Perl:my $lbl = parent->new_ttk__label(-text => "Name:");
Python:lbl = ttk.Label(parent, text="Name:")

Common Options

text The text string to be shown in the label.
textvariable As an alternative to text, get the string from a variable, updating when the variable changes.
Specify a Tk Image object (not the path to an image file) instead of the text string. If compound is center, top, bottom, left, or right, display the text and the image.
justify Alignment of text: left, center or right.
wraplength For multi-line labels; let Tk calculate the line breaks rather than explicitly embedding newlines in the text string.