This is an unofficial mirror of Tkinter reference documentation (based on Python 2.7 and Tk 8.5) created by the late John Shipman.
It was last updated in 2013 and is unmaintained. [More info]
The purpose of an Entry
widget is to allow the
user to enter or edit a single line of text. This is the
ttk version of Section 10, “The Entry
widget”.
To create a ttk.Entry
widget as the child of
a given
widget:
parent
w
= ttk.Entry(parent
,option
=value
, ...)
Options:
Table 40. ttk.Entry
options
class_
| The widget class name. This may be specified when the widget is created, but cannot be changed later. For an explanation of widget classes, see Section 27, “Standardizing appearance”. |
cursor
| The cursor that will appear when the mouse is over the checkbutton; see Section 5.8, “Cursors”. |
exportselection
|
By default, if you select text within an Entry widget, it is automatically exported
to the clipboard. To avoid this exportation, use
exportselection=0 .
|
font
| Use this option to specify the font of the text that will appear in the widget; see Section 5.4, “Type fonts”. For reasons that are unclear to the author, this option cannot be specified with a style. |
invalidcommand
|
You may set this option to a callback function that will
be called whenever validation fails (that is, when the
validatecommand returns a 0). See Section 10.2, “Adding validation to an Entry
widget”.
|
justify
|
This option specifies how the text will be positioned
within the entry area when it does not completely fill
the area. Values may be tk.LEFT to
left-justify; tk.CENTER to center; or
tk.RIGHT to right-justify.
|
show
|
To protect fields such as passwords from being visible
on the screen, set this option to a string, whose first
character will be substituted for each of the actual
characters in the field. For example, if the field
contains “ sesame ” but you
have specified show='*' , the field will
appear as “****** ”.
|
style
| The style to be used in rendering this checkbutton; see Section 49, “Using and customizing ttk styles”. |
takefocus
|
By default, a ttk.Checkbutton will
be included in focus traversal; see Section 53, “Focus: routing keyboard input”. To remove the widget from focus
traversal, use takefocus=False .
|
textvariable
| A variable that controls the text that appears in the entry area; see Section 52, “Control variables: the values behind the widgets”. |
validate
|
You may use this option to specify a callback function
that dynamically validates the widget's text content.
See Section 10.2, “Adding validation to an Entry
widget”.
|
validatecommand
|
See Section 10.2, “Adding validation to an Entry
widget”.
|
width
| This option specifies the width of the entry area as a number of characters. The actual width will be this number times the average width of a character in the effective font. The default value is 20. |
xscrollcommand
|
If the widget has an associated horizontal scrollbar,
set this option to the .set method of
that scrollbar.
|
These options of the Tkinter Entry
widget are
not supported by the ttk.Entry
widget constructor:
Table 41. Tkinter Entry
options not in ttk.Entry
background or bg
|
Configure the background option using a
style; see Section 47, “Customizing and creating ttk themes and styles”. The bg abbreviation is not supported.
|
borderwidth or bd
| Configure this option using a style. |
disabledbackground
|
Use a style map for the background
option; see Section 50.2, “ttk style maps: dynamic appearance
changes”.
|
disabledforeground
|
Use a style map for the foreground
option; see Section 50.2, “ttk style maps: dynamic appearance
changes”.
|
foreground or fg
| Configure this option using a style. |
highlightbackground
|
To control the color of the focus highlight when the
checkbutton does not have focus, use a style map to
control the highlightcolor option; see
Section 50.2, “ttk style maps: dynamic appearance
changes”.
|
highlightcolor
| You may specify the default focus highlight color by setting this option in a style. You may also control the focus highlight color using a style map. |
highlightthickness
| Configure this option using a style. This option may not work in all themes. |
insertbackground
| Not supported. |
insertborderwidth
| Not supported. |
insertofftime
| Not supported. |
insertontime
| Not supported. |
insertwidth
| Not supported. |
readonlybackground
|
Use a style map to control the background
option; see Section 50.2, “ttk style maps: dynamic appearance
changes”.
|
relief
| Configure this option using a style; see Section 47, “Customizing and creating ttk themes and styles”. |
selectbackground
|
Use a style map to control the background
option; see Section 50.2, “ttk style maps: dynamic appearance
changes”.
|
selectborderwidth
|
Use a style map to control the borderwidth option; see Section 50.2, “ttk style maps: dynamic appearance
changes”.
|
selectforeground
|
Use a style map to control the foreground
option; see Section 50.2, “ttk style maps: dynamic appearance
changes”.
|
Methods on a ttk.Entry
include all those
described in Section 46, “Methods common to all ttk widgets”, plus all the
methods on the Tkinter widget described in Section 10, “The Entry
widget”.