use strict; use Tk; my $mw= MainWindow->new; $mw->title('vartext'); my $f = $mw->Frame->pack(-side=>'bottom'); $f->Button(-text=>'Print',-command=>\&print_info)->pack(-side=>'left'); my $t=$mw->Scrolled("Text", -width=>40, -wrap=>'none')->pack(-expand=>1, -fill=>'both'); my @widget_list = (); my @strings = (" a..5 a.10 a.15 a.20 a.25 a.30 a.35 a.40 a.45 a.50", " b..5 b.10 b.15 b.20 b.25 b.30 b.35 b.40", " c..5 c.10 c.15 c.20 c.25 c.30", " d..5 d.10 d.15 d.20", ); my $wdth = 20; foreach ( @strings ) { my $hght = int( length() / $wdth ); $hght++ if ( length() % $wdth ); my $w= $t->Text( -width=>20, -height=>$hght, -wrap=>'char'); $w->insert('end',$_); $t->windowCreate('end',-window=>$w); $t->insert('end', "\n"); push @widget_list, $w; } sub print_info { foreach my $text (@widget_list) { print join " ", $text->yview; print "\n"; my $index = $text->index('end'); print qq§ index : $index \n§; } print "----------\n"; } MainLoop;