12.07.2015 Views

Tkinter reference: A GUI for Python

Tkinter reference: A GUI for Python

Tkinter reference: A GUI for Python

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

textvariable In order to be able to retrieve the current text fromyour entry widget, you must set this option to an instanceof the StringVar class; see Control variables,below. You can then retrieve the text using v.get()and set it using v.set(), where v is the associatedcontrol variable.width The size of the entry in characters. For proportionalfonts, the physical length of the widget willbe based on the average width of a character timesthe value of the width option. The default is 20.xscrollcommand If you expect that users will often enter more textthan the onscreen size of the widget, you can linkyour entry widget to a scrollbar. Set this option tothe .set method of the scrollbar. See below <strong>for</strong>more on scrollable entry widgets.Methods on Entry objects include:.delete ( first, last=None )Deletes characters from the entry. The first argument is the index of the first characterto be deleted. The last argument can be: Omitted: the single character at position first is deleted. Set to an integer: characters up to but not including the one at position last aredeleted. Set to the string "end": Characters are deleted up to the end..get()Returns the entry’s current text as a string..icursor ( index )Set the insertion cursor just be<strong>for</strong>e position index..index ( index )Shift the contents of the entry so that the character at position index is the leftmost visiblecharacter. Has no effect if the text fits entirely within the entry..insert ( index, s )Inserts string s be<strong>for</strong>e the character at position index..xview ( index )Same as .index()..xview_moveto ( )Positions the text in the entry so that the character at position , relative to the entire text,is positioned at the left edge of the window. The argument must be in the range [0; 1],where 0 means the left end of the text and 1 the right end..xview_scroll ( number, what )Used to scroll the entry horizontally. The what argument must be either "units", toscroll 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. Examples:entry.xview_scroll(-1, "pages")entry.xview_scroll(4, "units")# 1 page to the right# 4 chars to the leftNew Mexico Tech Computer Center <strong>Tkinter</strong> <strong>reference</strong>: The Entry widget Page 27

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!