-->
Previous | Table of Contents | Next |
Menu widgets are used to implement pull-down menus, cascading menus, and pop-up menus. A menu is a top-level widget that contains a set of menu entries that have values or commands associated with them. Five kinds of entries can be used in menus:
The main difference between the menu entries and the button widgets is that the button widgets can exist by themselves, but the menu entries must exist within the context of a menu widget.
Menu button widgets are similar to button widgets. The only real difference between the two is that when menu buttons are invoked they bring up menus instead of executing Tcl scripts as button widgets do. The menu button name usually describes the types of menu entries contained in the menu that the menu button activates. This means that you will find menu entries that perform some kind of file operations contained within the File menu.
You can activate a menu by moving the mouse pointer to the menu button widget and pressing the left mouse button. This activates the menu associated with the menu button and displays the menu entries that are contained in that menu to the screen. You can now move the mouse pointer down through the list of menu entries and select the one you want.
The File menu contains two command entries (the Open entry and Quit entry), one cascade entry (the Save As entry), and one separator entry. The menu that comes up as a result of clicking the mouse pointer on the Save As cascade entry contains three command entries: the Text entry, the Ver 1 file entry, and the Ver 2 file entry.
The list box widget enables users of a Tk application to select items from a list of one or more items. If the number of items to be displayed in the list box is larger than the number of lines in the list box, you can attach scrollbars to make the extra items accessible.
Scrollbar widgets are used to control what is displayed in other widgets. Scrollbar widgets are attached to other widgets to allow users to scroll up and down through the information contained in the widget. You typically put scrollbars on any widget that is designed to contain an arbitrary number of lines of information (such as a list box) or on widgets that contain more lines of information than the widget can display, given its size.
This chapter starts off by introducing Tcl and the Tk tool kit and describes the uses of both. Although this chapter contains a lot of information, it barely scratches the surface of the programming tools provided by Tcl and the Tk tool kit.
Tcl has many more programming features than described in this book. Some of the most notable are arrays, lists, and procedures. Not all of the Tk widgets are described here, either. Some of the widgets we did not go into are canvasses, scales, labels, messages, and textedit widgets. If you are interested in learning more about Tcl and Tk, check out a book on the subject.
Tk is just one example of an extension to Tcl. There are many other extensions available that extend the behavior of Tcl in different ways. Some of these extensions are as follows:
To learn more about
Previous | Table of Contents | Next |