use strict; use Tk; use Tk::ROText; my $main = MainWindow->new; my $b = $main->Button(-text => 'count', -command => \&count )->pack; my $t = $main->ROText(width => 80, height => 10) ->pack(); MainLoop; sub count { my $i = 0; my $count; while ($i<20) { $t->insert("end", "Line $i\n"); $t->update(); sleep 1; $i++; } }