Without seeing the rest of your code and not really sure what value the widget ( $t->index('insert') ) is actually returning, you said '2.0'... Since I am not sure what widget you are using... I would maybe try qq/ $t->index('insert')/ or $t->index('insert').""... since perl may be trying to cast the index into a number instead of leaving it as a string
The following works for me on AS 5.8.3 build 809 and Tk 804.021:
use Tk;
use strict;
my $mw = tkinit;
$mw->geometry('100x100');
my $linenumbers = $mw->Text()->pack(-fill, 'both', -expand, 1);
&line_num(30);
MainLoop;
sub line_num {
my $total_lines = shift;
#my $line_number = qq($t->index('insert')); #?
my $line_number = '21.0';
print $line_number,"\n";
$linenumbers->delete("0.1", "end");
for (0..$total_lines) {
$linenumbers->insert('end', join "\n", map {sprintf "%4d\n", $_
+} $_);
}
#$linenumbers->yviewMoveto($line_number/$total_lines);
#$linenumbers->yview(-pickplace, $line_number);
$linenumbers->see($line_number);
}
JamesNC
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.