Tkinter Entry
Tkinter Entry
command A procedure to be called every time the user changes the state of
this checkbutton.
cursor If you set this option to a cursor name (arrow, dot etc.), the mouse
cursor will change to that pattern when it is over the checkbutton.
highlightcolor The color of the focus highlight when the checkbutton has the focus.
justify If the text contains multiple lines, this option controls how the text is justified:
CENTER, LEFT, or RIGHT.
Entry: Options
Option Description
relief With the default value, relief=FLAT, the checkbutton does not stand out from its
background. You may set this option to any of the other styles
selectborderwidth The width of the border to use around selected text. The default is one pixel.
show Normally, the characters that the user types appear in the entry. To make a
.password. entry that echoes each character as an asterisk, set show="*".
state The default is state=NORMAL, but you can use state=DISABLED to gray out the
control and make it unresponsive. If the cursor is currently over the
checkbutton, the state is ACTIVE.
textvariable In order to be able to retrieve the current text from your entry widget, you must
set this option to an instance of the StringVar class.
width The default width of a checkbutton is determined by the size of the displayed
image or text. You can set this option to a number of characters and the
checkbutton will always have room for that many characters.
xscrollcommand If you expect that users will often enter more text than the onscreen size of the
widget, you can link your entry widget to a scrollbar.
Entry: Methods
Method Description
delete ( first, last=None ) Deletes characters from the widget, starting with the one at index first,
up to but not including the character at position last. If the second
argument is omitted, only the single character at position first is deleted.
icursor ( index ) Set the insertion cursor just before the character at the given index.
index ( index ) Shift the contents of the entry so that the character at the given index is
the leftmost visible character. Has no effect if the text fits entirely
within the entry.
insert ( index, s ) Inserts string s before the character at the given index.
select_adjust ( index ) This method is used to make sure that the selection includes the
character at the specified index.
select_clear() Clears the selection. If there isn't currently a selection, has no effect.
select_from ( index ) Sets the ANCHOR index position to the character selected by index, and
selects that character.
Entry: Methods
Method Description
select_present() If there is a selection, returns true, else returns false.
select_range ( start, end ) Sets the selection under program control. Selects the text starting
at the start index, up to but not including the character at the end
index. The start position must be before the end position.
select_to ( index ) Selects all the text from the ANCHOR position up to but not
including the character at the given index.
xview ( index ) This method is useful in linking the Entry widget to a horizontal
scrollbar.
xview_scroll ( number, what ) Used to scroll the entry horizontally. The what argument must be
either UNITS, to scroll by character widths, or PAGES, to scroll by
chunks the size of the entry widget. The number is positive to scroll
left to right, negative to scroll right to left.