Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hello wise monks, I have the following frame
$frame = $lower_frame->Scrolled('Frame', -scrollbars => + "e", -height => '300')->pack(-fill => "x",-anchor=>'w');
Later on I feel it with checkbuttons and in certain scenario I want to set the yscroll position back to 0. I tried
$frame->yviewMoveto(0);
and
$frame->yview(moveto => 0);
as suggested in
http://search.cpan.org/~ni-s/Tk/Tk/Pane.pm
Please help, Thanks

Replies are listed 'Best First'.
Re: Setting the yview position in scrolled
by kcott (Archbishop) on Jul 18, 2013 at 07:35 UTC

    You've almost answered your question yourself. Tk::Frame is non-interactive. The first sentence of Tk::Pane - DESCRIPTION:

    "Tk::Pane provides a scrollable frame widget."

    Change

    ... Scrolled('Frame', ...

    to

    ... Scrolled('Pane', ...

    and you'll probably have more luck. :-)

    -- Ken

      Sorry - no go, I also tried with Pane and I get: Tk::Error: Can't call method "Call" on an undefined value at /usr/local/perl5.8.6/lib/site_perl/5.8.6/i686-linux/Tk/Pane.pm line 346, <DATA> line 6.
        #!/usr/bin/perl -- use strict; use warnings; use Tk; my $mw = tkinit; my $target = 45; my $tmax = 60; my $bb = $mw->Button( -text => 'JT' )->pack;; my $tt = $mw->Entry( -textvariable => \$target )->pack; my $br = $mw->Button( -text => 'RJ' )->pack;; my $fr = $mw->Scrolled('Frame')->pack; $fr->Button( -text => $_ )->pack for 0 .. $tmax; $bb->configure( -command => [ \&dothat, $fr, \$target, $tmax ] ); $br->configure( -command => [ \&dothat, $fr, \$target, $tmax , 'random +'] ); MainLoop; sub dothat { my( $fr, $tgr, $tm , $random ) = @_; $random and $$tgr = int rand $tm; my $tg = $$tgr / $tm; $fr->yview( moveto => $tg ); return; } __END__
        show your code
Re: Setting the yview position in scrolled
by Anonymous Monk on Jul 18, 2013 at 07:11 UTC

    If you can post runnable code, I'll take a look at it, thanks