O'Reilly logo

Learning Perl/Tk by Nancy Walsh

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 8. The Text Widget

When you think about what a text widget might do, you automatically think, "it displays text." This is true, yet it can do quite a bit more. The text widget is one of the most powerful standard widgets available in Perl/Tk. It is flexible, configurable, and easy to use for simple tasks. Here are some examples of how you can use text widgets:

  • Display and edit a plain text file.

  • Display formatted text from an HTML document.

  • Create a scrollable color key, with buttons that allow you change the colors

  • Gather multiline, formatted text (including colors) from a user (mini word processor).

  • Display text with different colors based on the input.

  • Make certain portions of text "clickable" and perform an action when clicked on. This could be HTML, or it could be similar to the widget demo.[1]

    [1] When you installed the Tk module with Perl, you also installed the widget demo. Type widget on the command line to see the capabilities of widgets in Perl/Tk.

You can put simple text, formatted text, and other widgets inside a text widget. A text widget can be used in conjunction with scrollbars to allow many pages of information to be viewed in much less space.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required