in reply to Inactive Scroll Bar - Scrolled Listbox
#!/usr/bin/perl -w use strict; use Tk; my $main = MainWindow->new; my $list = $main->Scrolled('Listbox', -scrollbars => 'e', -selectmode => 'single')->pack; foreach my $i (1..100) { $list->insert('end', "item $i"); } my $button = $main->Button(-text => "Scroll to Bottom of List", -command => \&scroll_to_bottom)->pack; MainLoop; sub scroll_to_bottom { my ($first, $last) = $list->Subwidget("yscrollbar")->get; print "Listbox window is from $first to $last\n"; # set to end of list my $winsize = $last - $first; $first = 1.0 - $winsize; $last = 1.0; $list->Subwidget("yscrollbar")->set($first, $last); $list->see('end'); #scroll all the way down #$list->see('55'); #scroll to some index print "Set listbox window from $first to $last\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Inactive Scroll Bar - Scrolled Listbox
by Araviz (Initiate) on Apr 12, 2011 at 16:42 UTC | |
by lamprecht (Friar) on Apr 12, 2011 at 16:56 UTC | |
by Araviz (Initiate) on Apr 12, 2011 at 18:17 UTC |