| Previous | Next
Scrollbar WidgetContents:Defining Scrollbar Parts
Scrollbars are used with widgets when there is more to see than can be shown at once. Scrollbars allow a user to scroll a widget's contents horizontally and/or vertically. This chapter shows how you can use Scrollbars with certain Perl/Tk widgets. Defining Scrollbar PartsFigure 6-1 shows all the different parts of a Scrollbar and their names. Figure 6-1. Different parts of a ScrollbarThe trough is the sunken part between the two arrows. It is divided into two parts, Clicking on either arrow will move the information in the associated widget one unit at a time. What the unit is depends on the type of widget with which the Scrollbar is associated. With an Entry widget, the units are characters. With a Listbox widget and a vertical Scrollbar, the units are lines. Clicking in the trough on either side of the slider will page the information in the widget in that direction. You can also click directly on the slider and, holding the mouse button down, move it directly. Scrollbars can be horizontal or vertical. They typically reside on the bottom and/or to the right of the widget they are scrolling, but not always. Not just any widget can have scrollbars attached to it. Generally speaking, for a widget to be scrollable, it must have Figure 6-2. Entry widget with a Scrollbar
Figure 6-3. Listbox widget with Scrollbar
Figure 6-4. Text widget displaying Scrollbar.pm file with Scrollbar
Figure 6-5. Canvas widget with ScrollbarsThere are two ways to create and configure Scrollbars for use with widgets: you can use the |