The widget roundup provides you with a quick and easy reference to the most important features
and options for each Tk widget.
Entry
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. |
---|---|
Python: | name = StringVar() e = ttk.Entry(parent, textvariable=name) |
Tcl: | ttk::entry .e -textvariable name |
Ruby: | $name = TkVariable.new ( initialValue ); e = Tk::Tile::Entry.new(parent) {textvariable $name} |
Perl: | my $e = parent->new_ttk__entry(-textvariable => $name); |
Reference: | (at www.tcl.tk) |
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). |