Chapter 8. The Text, TextUndo,and ROText Widgets

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. You can use Text widgets to:

  • 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 (act as a mini word processor)

  • Display text with different colors based on the input

  • Create hypertext windows that perform actions when clicked (either HTML or similar to the widget demo).[1]

You can put text as well as 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.

[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.

Get Mastering Perl/Tk now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.