next up previous contents
Next: Scrollbars Up: Basic Widgets Previous: Labels and Messages

Entry

 

An entry box is a box which contains one editable line of text. If is used to input short texts, such as a name or a credit card number.

As opposed to previous widgets, entries are polymorph over the type of values they are supposed to hold and edit, hence an entry is created with

The current state of the input is the value of the entry; it is accessed and set with the configuration from the class Configuration.html#Configuration.HasValueHasValue. Note that the values need not be strings, but must be an instance of GUIValue.

Tk only provides the basic editing functions for entry widgets. If you want anything more, for example to read the value of the entry when the return key is pressed, you have to do this yourself by binding to the KeyPress event. Here is a very basic example of how to use an entry widget: we build an entry widget, and when the return key is pressed, we change the window title to the entered text, and clear the entry widget.



An alternative to using values is to use TkVariables. These are variables on the Tk side, which can be directly connected to the widget in the sense that the variable always holds the entry's state. The advantage of this approach is that we can share values across widgets (see Mainhello3.hs in htk/examples/simple).

Finally, entry widgets implement the quite flexible indexing and selection classes (see Sect. 6.1 and 6.2 below).



Christoph Lueth
Wed May 29 13:20:38 MEST 2002