These examples are included to hopefully clear up any confusion about how to use scrollbars in the real world. Each example uses the Scrolled method if possible; then we do the same thing manually. We haven't covered all the widget types we are using here, but we aren't doing anything fancy with them either. If you see an option or method you don't recognize, just see the appropriate chapter for that widget to learn more.
The entry widget can only be scrolled horizontally. The entry can only contain one line of text at most, so a vertical scrollbar would do nothing. Using Scrolled to create a scrolled entry widget is easy:
$mw->Scrolled("Entry", -scrollbars => "s", -width => 30)->pack();
If you want to make the scrollbar only show when the data in the entry widget requires it, use -scrollbars => "os". Using the Scrollbar method is a bit more work:
$scrollbar = $mw->Scrollbar(-orient => 'horizontal'); $entry = $mw->Entry(-width => 30, -xscrollcommand => ['set' , $scrollbar]); $scrollbar->configure(-command => ['xview', $entry]); $scrollbar->pack(-side => 'bottom', -fill => 'x'); $entry->pack(-side => 'bottom', -fill => 'x');
Both will create an entry that looks similar to the one in Figure 6.13.
A listbox widget can be scrolled both horizontally and vertically, ...