Skip to Main Content
Perl in a Nutshell, 2nd Edition
book

Perl in a Nutshell, 2nd Edition

by Nathan Patwardhan, Ellen Siever, Stephen Spainhour
June 2002
Beginner content levelBeginner
759 pages
80h 42m
English
O'Reilly Media, Inc.
Content preview from Perl in a Nutshell, 2nd Edition

The Scrollbar widget

For more flexibility with a scrollbar, you can use the Scrollbar widget. To do so, you need to create the target widget to scroll. Set the -xscrollcommand or -yscrollcommand option as appropriate, configure the scrollbar to talk to the widget, and position the scrollbar and target widget next to one another. For example:

$scrollbar = $mainwindow->Scrollbar(-orient => 'vertical');
$listbox = $mainwindow->Entry(-yscrollcommand => ['set' => $scrollbar]);
$scrollbar->configure(-command => ['yview' => $listbox]);
$scrollbar->pack(-side => 'right', -fill => 'y');
$listbox->pack(-side => 'left', -fill => 'both');

First, we create the scrollbar with vertical orientation (which is actually the default). Next, we create the Listbox widget with the -yscrollcommand option to define a callback when the widget is scrolled vertically. The scrollbar is then configured with a callback that says to inform the Listbox widget when it is clicked vertically. Finally, the Scrollbar and Listbox widgets are packed side-by-side. See further discussion of the Scrollbar widget later in this chapter for more information.

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Perl by Example, Fourth Edition

Perl by Example, Fourth Edition

Ellie Quigley
Perl Cookbook, 2nd Edition

Perl Cookbook, 2nd Edition

Tom Christiansen, Nathan Torkington
Perl in a Nutshell

Perl in a Nutshell

Nathan Patwardhan, Ellen Siever, Stephen Spainhour
Learning Perl, 7th Edition

Learning Perl, 7th Edition

Randal L. Schwartz, brian d foy, Tom Phoenix

Publisher Resources

ISBN: 0596002416Errata Page