15 Text Widgets
This chapter explains how the Text and TextField widgets can be used to provide text−entry capabilities in an
application. These widgets can be used for a variety of purposes, from a simple data−entry field to a full−fledged text
editor. The chapter describes the selection mechanisms provided by the widgets and how they can be used to
communicate with other applications via the clipboard. The widgets also allow the programmer to control the format
of the data that is entered by the user.
Despite all that can be done with menus, buttons, and lists, there are times when the user can best interact with an
application by typing at the keyboard. The Text widget is usually the best choice for providing this style of interface,
as it provides full−featured text editing capabilities. The Text widget can be used anywhere the user might be expected
to type free−form text, such as in a compose window in a mail application. Unlike standard text editors, the Text
widget supports the point−and−click model that people expect from GUI−based applications. The TextField widget
provides a single−line data entry field with the same set of editing commands as the Text widget, but it requires less
overhead. Text widgets can also be used in output−only mode to display more textual information than is practical
with a label or a button.
Even though the text widgets allow for complex interaction, they still provide simple mechanisms for program
control. The widgets have resources that access the text, ...