in reply to Inactive Scroll Bar - Scrolled Listbox

I don't see your problem, but you are not showing a complete running example. How does this run for you?
#!/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"; }

I'm not really a human, but I play one on earth.
Old Perl Programmer Haiku ................... flash japh

Replies are listed 'Best First'.
Re^2: Inactive Scroll Bar - Scrolled Listbox
by Araviz (Initiate) on Apr 12, 2011 at 16:42 UTC

    The code you posted works fine. What part is of my code would you like to see? It's a very large script so I tried to pull the parts related to the scroll bar.

      Here is a complete runnable example, that demonstrates the problem:

      use strict; use warnings; use Tk; my $mw = tkinit; my $frm1 = $mw -> Frame(-bg=>'LightSkyBlue1') -> pack(-fill => 'x'); my $frm11 = $frm1 -> Frame(-bg=>'LightSkyBlue1') -> pack(-fill => 'x') +; my $lst = $frm11 -> Scrolled('Listbox', -width => 50, -height => 5, -scrollbars => 'oe', -selectmode => 'single') -> pack(); $mw->update; $lst -> delete ('0.0', 'end'); $lst -> insert('end',(0..10)); $mw->update; # force scrollbar refresh: # my $sb = $lst->Subwidget('yscrollbar'); # $sb->set( $sb->get ); MainLoop;
      See also:
      Re: Perl/Tk Optional Vertical Scrollbar Bugfix

      Cheers, Christoph
        That works! Thank you!