I'm not really positive what you are trying to accomplish. If you just want visible line numbers at the start of each line, try the Tk::LineNumberText module, I've used it several times and it works nicely.
If you just want to know the current line and column, you can do something simple like this:
Update: Made text Scrolled.
use warnings; use strict; use Tk; my $mw = MainWindow->new; my $index = 'Line: 1 - Column: 0'; my $txt = $mw->Scrolled('Text', -scrollbars => 'se', -wrap => 'none', -background => 'white', -width => 40, -height => 30, -selectbackground => 'skyblue', -insertwidth => 5, -borderwidth => 3, -highlightcolor => 'blue', ### after visit -highlightbackground => 'red', ### default before visit -padx => 5, -pady => 5, )->pack(); my $label = $mw->Label( -textvariable => \$index )->pack(); $txt->bind( '<Key>', \&update_index ); MainLoop; sub update_index { my ( $line, $column ) = split( /\./, $txt->index('insert') ); $index = "Line: $line - Column: $column"; }
In reply to Re: [PERL Tk] printing Line number in Text widget.
by thundergnat
in thread [PERL Tk] printing Line number in Text widget.
by ungalnanban
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |