The Tkinter Entry Class
- Entry(master=None, **options) (class) [#]
A text entry field.
- Parent widget.
- Widget options. See the description of the config method for a list of available options.
- config(**options) [#]
Modifies one or more widget options. If no options are given, the method returns a dictionary containing all current option values.
- Widget options.
- Widget background. The default is system specific. (the option database name is background, the class is Background)
- Same as background.
- Border width. The default is system specific, but is usually a few pixels. (borderWidth/BorderWidth)
- Same as borderwidth.
- Widget cursor. The default is a text insertion cursor (typically an “I-beam” cursor, e.g. xterm). (cursor/Cursor)
- Background to use when the widget is disabled. If omitted or blank, the standard background is used instead. (disabledBackground/DisabledBackground)
- Text color to use when the widget is disabled. If omitted or blank, the standard foreground is used instead. (disabledForeground/DisabledForeground)
- If true, selected text is automatically exported to the clipboard. Default is true. (exportSelection/ExportSelection)
- Widget font. The default is system specific. (font/Font)
- Text color. (foreground/Foreground)
- Same as foreground.
- Together with highlightcolor, this option controls how to draw the focus highlight border. This option is used when the widget doesn’t have focus. The default is system specific. (highlightBackground/HighlightBackground)
- Same as highlightbackground, but is used when the widget has focus. (highlightColor/HighlightColor)
- The width of the focus highlight border. Default is typically a few pixels, unless the system indicates focus by modifying the button itself (like on Windows). (highlightThickness/HighlightThickness)
- Color used for the insertion cursor. (insertBackground/Foreground)
- Width of the insertion cursor’s border. If this is set to a non-zero value, the cursor is drawn using the RAISED border style. (insertBorderWidth/BorderWidth)
- Together with insertontime, this option controls cursor blinking. Both values are given in milliseconds. (insertOffTime/OffTime)
- See insertofftime. (insertOnTime/OnTime)
- Width of the insertion cursor. Usually one or two pixels. (insertWidth/InsertWidth)
- FIXME. No default. (invalidCommand/InvalidCommand)
- Same as invalidcommand.
- How to align the text inside the entry field. Use one of LEFT, CENTER, or RIGHT. The default is LEFT. (justify/Justify)
- The background color to use when the state is “readonly”. If omitted or blank, the standard background is used instead. (readonlyBackground/ReadonlyBackground)
- Border style. The default is SUNKEN. Other possible values are FLAT, RAISED, GROOVE, and RIDGE. (relief/Relief)
- Selection background color. The default is system and display specific. (selectBackground/Foreground)
- Selection border width. The default is system specific. (selectBorderWidth/BorderWidth)te
- Selection text color. The default is system specific. (selectForeground/Background)
- Controls how to display the contents of the widget. If non-empty, the widget displays a string of characters instead of the actual contents. To get a password entry widget, set this option to “*”. (show/Show)
- The entry state: NORMAL, DISABLED, or “readonly” (same as DISABLED, but contents can still be selected and copied). Default is NORMAL. Note that if you set this to DISABLED or “readonly”, calls to insert and delete are ignored. (state/State)
- Indicates that the user can use the Tab key to move to this widget. Default is an empty string, which means that the entry widget accepts focus only if it has any keyboard bindings (default is on, in other words). (takeFocus/TakeFocus)
- Associates a Tkinter variable (usually a StringVar) to the contents of the entry field. (textVariable/Variable)
- Specifies when validation should be done. You can use “focus” to validate whenever the widget gets or loses the focus, “focusin” to validate only when it gets focus, “focusout” to validate when it loses focus, “key” on any modification, and ALL for all situations. Default is NONE (no validation). (validate/Validate)
- A function or method to call to check if the contents is valid. The function should return a true value if the new contents is valid, or false if it isn’t. Note that this option is only used if the validate option is not NONE. (validateCommand/ValidateCommand)
- Same as validatecommand.
- Width of the entry field, in character units. Note that this controlS the size on screen; it does not limit the number of characters that can be typed into the entry field. The default width is 20 character. (width/Width)
- Used to connect an entry field to a horizontal scrollbar. This option should be set to the set method of the corresponding scrollbar. (xScrollCommand/ScrollCommand)
- delete(first, last=None) [#]
Deletes the character at index, or within the given range. Use delete(0, END) to delete all text in the widget.
- Start of range.
- Optional end of range. If omitted, only a single character is removed.
- get() [#]
Gets the current contents of the entry field.
- The widget contents, as a string.
- icursor(index) [#]
Moves the insertion cursor to the given index. This also sets the INSERT index.
- Where to move the cursor.
- index(index) [#]
Gets the numerical position corresponding to the given index.
- An index.
- The corresponding numerical index.
- insert(index, string) [#]
Inserts text at the given index. Use insert(INSERT, text) to insert text at the cursor, insert(END, text) to append text to the widget.
- Where to insert the text.
- The text to insert.
- scan_dragto(x) [#]
Sets the scanning anchor for fast horizontal scrolling to the given mouse coordinate.
- Current horizontal mouse position.
- scan_mark(x) [#]
Scrolls the widget contents sideways according to the given mouse coordinate. The text is moved 10 times the distance between the scanning anchor and the new position.
- Current horizontal mouse position.
- select_adjust(index) [#]
Same as selection_adjust.
- select_clear() [#]
Same as selection_clear.
- select_from(index) [#]
Same as selection_from.
- select_present() [#]
Same as selection_present.
- select_range(start, end) [#]
Same as selection_range.
- select_to(index) [#]
Same as selection_to.
- selection_adjust(index) [#]
Adjusts the selection to include also the given character. If index is already selected, do nothing.
- The index.
- selection_clear() [#]
Clears the selection.
- selection_from(index) [#]
Starts a new selection. This also sets the ANCHOR index.
- The index.
- selection_present() [#]
Checks if text is selected.
- A true value if some part of the text is selected.
- selection_range(start, end) [#]
Explicitly sets the selection range. Start must be smaller than end. Use selection_range(0, END) to select all text in the widget.
- Start of selection range.
- End of range.
- selection_to(index) [#]
Selects all text between ANCHOR and the given index.
- xview(index) [#]
Makes sure the given index is visible. The entry view is scrolled if necessary.
- An index.
- xview_moveto(fraction) [#]
Adjusts the entry view so that the given offset is at the left edge of the canvas. Offset 0.0 is the beginning of the entry string, 1.0 the end.
- xview_scroll(number, what) [#]
Scrolls the entry view horizontally by the given amount.
- Number of units.
- What unit to use. This can be either “units” (characters) or “pages” (larger steps).