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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

.tag_add ( tagName, index1, index2=None )This method associates the tag named tagName with a region of the contents startingjust after index index1 and extending up to index index2. If you omit index2, only thecharacter after index1 is tagged..tag_bind ( tagName, sequence, func, add=None )This method binds an event to all the text tagged with tagName. See Events, below, <strong>for</strong>more in<strong>for</strong>mation on event bindings.To create a new binding <strong>for</strong> tagged text, use the first three arguments: sequence identifiesthe event, and func is the function you want it to call when that event happens.To add another binding to an existing tag, pass the same first three arguments and "+"as the fourth argument.To find out what bindings exist <strong>for</strong> a given sequence on a tag, pass only the first twoarguments; the method returns the associated function.To find all the bindings <strong>for</strong> a given tag, pass only the first argument; the method returnsa list of all the tag’s sequence arguments..tag_cget ( tagName, option )Use this method to retrieve the value of the given option <strong>for</strong> the given tagName..tag_config ( tagName, *options )To change the value of options <strong>for</strong> the tag named tagName, pass in one or more option=valuepairs.If you pass only one argument, you will get back a dictionary defining all the optionsand their values currently in <strong>for</strong>ce <strong>for</strong> the named tag.Here are the options <strong>for</strong> tag configuration:backgroundbgstippleborderwidthfgstipplefont<strong>for</strong>egroundjustifylmargin1The background color <strong>for</strong> text with this tag. Notethat you can’t use bg as an abbreviation.To make the background appear grayish, set thisoption to one of the standard bitmap names"gray12", "gray25", "gray50", or "gray75"(from lighter to darker). This has no effect unlessyou also specify a background.Width of the border around text with this tag.Default is 0. Note that you can’t use bd as anabbreviation.To make the text appear grayish, set this option toone of the standard bitmap names specified aboveunder bgstipple.The font used to display text with this tag.The color used <strong>for</strong> text with this tag. Note that youcan’t use the fg abbreviation here.The justify option set on the first character of eachline determines how that line is justified: LEFT (thedefault), CENTER, or RIGHT.How much to indent the first line of a chunk of textthat has this tag. The default is 0.New Mexico Tech Computer Center <strong>Tkinter</strong> <strong>reference</strong>: The Text widget Page 56

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

Saved successfully!

Ooh no, something went wrong!