Tkinter Widget-Entry

Entry  is used to accept the strings from a user.

Syntax-

w = Entry( main, option, ... )
Main- Parent Window.
Option- attribute of button widget.

Example-
  1. from tkinter import *  
  2. main= Tk()  
  3. L1 = Label(main, text="User Name")  
  4. L1.pack( side = LEFT)  
  5. E1 = Entry(main, bd =5)  
  6. E1.pack(side = RIGHT)  
  7. main.mainloop()  
Output-
 
OptionDescription
bgNormal background color.
bdSets the border width in pixels. Default is 2.
command It is used to call a method or a function.
cursorCursor is used to create a cursor in canvas like arrow, circle, dot etc.
font
It is used to set the font style.
exportselectionIt is used to avoid the selection of the text on the clipboard.
fg 
It sets the normal foreground color of the text.

highlightcolor
Changes color of widgets on focus.
justify  It is used to justify the text of widgets.
relief
Relief is special type of border. The values are SUNKEN, RAISED, GROOVE and RIDGE.
selectbackgroundIt is used to set the background color.
selectborderwidth
It is used to set the border width around the selected text. Default 1 px
selectforeground
It is used to set foreground color of the selected text. 
showIt is used to set the type of text is appearing in entry like simple text or password.
state
 It is used to set the state of widgets, where the state is ACTIVE or DISABLE.
textvariable
It is used to store a value of an entry.
width
It is used to set the width of widgets.
 xscrollcommandIt is used to scroll on the defined value in x direction
 
Summary

In this chapter, you learnt what Entry widget is and how to use the property of the widget.
Next » Tkinter Widget-Frame