Skip to Main Content
Learning Perl/Tk
book

Learning Perl/Tk

by Nancy Walsh
January 1999
Beginner content levelBeginner
373 pages
9h 43m
English
O'Reilly Media, Inc.
Content preview from Learning Perl/Tk

8.5. Text Tags

Text tags give you another way to address portions of text in the text widget. A tag has three purposes, and the same tag can serve all three or only one:

  • Assigning formatting information to a portion(s) of text

  • Associating a binding with text in the widget

  • Managing selected text

Tags are also used to change how the text appears on the screen: font, size, coloring, and spacing are among a few of the text properties affected by tags. You change text properties by creating your own tags (with their own names), and using option/value pairs to assign formatting information. In addition to changing the formatting, you can use a tag to apply a specific binding (such as perform a task when the user clicks on that text). A special tag "sel" manages the selected text. Anytime the user selects some text, the location of that text is marked with the tag "sel".

Any of the text within the text widget can have one or more tags associated with it. If you apply two tags to the same piece of text and they both alter the font, the last tag applied wins.

8.5.1. Options Used With Tags

The options you can use to configure tagged text are mostly a subset of the configuration options of the text widget itself. There are some options that can only be used through tagged text.

-background => color

Sets the color of the area behind the text.

-bgstipple => pattern

Sets the pattern used to draw the area behind the text. Can create a shaded look.

-borderwidth => amount

Sets the width of ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Mastering Perl/Tk

Mastering Perl/Tk

Stephen Lidie, Nancy Walsh

Publisher Resources

ISBN: 1565923146Supplemental ContentCatalog PageErrata