You need the yview method, but that fails if there is nothing to be scrolled (if everything already fits), so you need some protection:
use strict; use warnings; use Tk; use Tk::Pane; my $mw = MainWindow->new (); $mw->geometry ("100x100"); $mw->Button (-text => "START", -command => \&start_computation)->pack; MainLoop; sub start_computation { my $progress = $mw->Toplevel (); my $sp = $progress->Scrolled ("Pane", Name => "Progress", -width => 200, -height => 100, -scrollbars => "ose", )->pack (-anchor => "nw", -fill => "both", -expand => 1); my $text = "Computation started...\n"; my $label = $sp->Label (-text => $text)->pack (); # doing several computation steps foreach my $step (1 .. 10) { sleep (1); $text .= "Step $step finished.\n"; $label->configure (-text => $text); my @pos = $sp->yview; $pos[1] < 1 and $sp->yview (moveto => 1.); $sp->update; } $text .= "\nComputation finished.\n"; $label->configure (-text => $text); $sp->yview (moveto => 1); $sp->update; $sp->Button (-text => "QUIT", -command => sub { exit; })->pack; } # start_computation
In reply to Re: Perl::Tk Vertical scrollbar on the bottom by default?
by Tux
in thread Perl::Tk Vertical scrollbar on the bottom by default?
by Microcebus
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |