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

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.
  • Comment on Re: Re: Re: Re: Re: Invoking scrolling externally on a Perl/Tk Scrolled widget
  • Download Code