in reply to Re: Re: Re: Invoking scrolling externally on a Perl/Tk Scrolled widget
in thread Invoking scrolling externally on a Perl/Tk Scrolled widget

I think the yviewMoveto method will work to get your widget where you want it; my understanding is it works on any Scrolled widget. (In my real project I needed to scroll a TableMatrix, but I didn't want to post a complex example here.)

You just need to pass the value of ($line_to_scroll_to/$total_lines) to the method.

Flashing I don't know about, though.

  • Comment on Re: Re: Re: Re: Invoking scrolling externally on a Perl/Tk Scrolled widget

Replies are listed 'Best First'.
Re: Re: Re: Re: Re: Invoking scrolling externally on a Perl/Tk Scrolled widget
by Elijah (Hermit) on Dec 02, 2003 at 20:06 UTC
    Ahh yes, worked great. I had to tweak it a bit to get it to scroll to the line I wanted to and not past it. For some reason is you hav 200 total lines and you tell it to scroll to the 50th line it would be 200/50 which would scrill to the 51st line (I am guessing rounding off the decimal or something). So what I did was I would prompt for what line to scroll to then subtract one and run it through the division and then readd 1 back to it again after I was done. I know that sounds a little confusing so here is the code, it might make more since then I can.
    sub go_to { my $sw = MainWindow->new(-title=>"Go To Line"); my $frame = $sw->Frame->pack(-side => 'top', -fill => 'x'); $frame->Label(-text => "Enter Line Number:")->pack(-side => 'left', + -anchor => 'w'); $frame->Entry(-textvariable => \$line_number)-> pack(-side => 'left', -anchor => 'w', -fill => 'x', -expand => 1 +); $frame->Button(-text => "GO", -background => 'navy blue', -foregrou +nd => 'white', -command =>\&scroll_line)-> pack(-side => 'right'); sub scroll_line { $line_number = $line_number - 1; my $calc = $line_number/$line_count; $t->yviewMoveto($calc); $line_number = $line_number + 1; } }
    Thanx again for the help.