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.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.