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.

.insert ( index, text, tags=None )Inserts the given text at the given index.If you omit the tags argument, the newly inserted text will be tagged with any tags thatapply to the characters both be<strong>for</strong>e and after the insertion point.If you want to apply one or more tags to the text you are inserting, provide as a thirdargument a sequence of tag strings. Any tags that apply to existing characters aroundthe insertion point are ignored..mark_gravity ( mark, gravity=None )Changes or queries the gravity of an existing mark; see Marks in text widgets, above,<strong>for</strong> an explanation of gravity. To set the gravity, pass in the name of the mark, followed byeither LEFT or RIGHT. To find the gravity of an existing mark, omit the second argumentand the method returns LEFT or RIGHT..mark_names()Returns a sequence of the names of all the marks in the window, including INSERT andCURRENT..mark_set ( mark, index )If no mark with name mark exists, one is created with RIGHT gravity and placed whereindex points. If the mark already exists, it is moved to the new location..mark_unset ( mark )Removes the named mark..search ( pattern, index, *options )Searches <strong>for</strong> pattern (which can be either a string or a regular expression) in the bufferstarting at the given index. If it succeeds, it returns an index of the "line.char" <strong>for</strong>m; ifit fails, it returns an empty string.The allowable options <strong>for</strong> this method are:backwardscountregexpnocasestopindex.see ( index )Set this option to 1 to search backwards from the index. Defaultis <strong>for</strong>wards.If you set this option to an IntVar control variable, when thereis a match you can retrieve the length of the text that matchedby using the .get() method on that variable after the methodreturns.Set this option to 1 to interpret the pattern as a Tcl-styleregular expression. The default is to look <strong>for</strong> an exact matchto pattern. Tcl regular expressions are a subset of <strong>Python</strong>regular expressions, supporting these features: . ^ $ [c 1 : : :](: : :) * + ? e 1 |e 2Set this option to 1 to ignore case. The default is a case-sensitivesearch.To limit the search, set this option to the index beyond whichthe search should not go.If the text containing the given index is not visible, scroll the text until it is.New Mexico Tech Computer Center <strong>Tkinter</strong> <strong>reference</strong>: The Text widget Page 55

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

Saved successfully!

Ooh no, something went wrong!