$fill_x->configure(-command => sub { $_->configure(-state => 'disabled') for $fill_x, $fill_y; my $ms = 50 * (1 + int rand 10); my $iters = 1 + int rand 100; my $iter = 0; my $id; my $label = 'LABEL'; $id = $mw->repeat($ms, sub { if (++$iter <= $iters) { text_show($text, sprintf "\r%s%4d/%4d [%s]", $label, $iter, $iters, '=' x $iter ); } else { text_show($text, "\nDone!\n"); $id->cancel; $_->configure(-state => 'normal') for $fill_x, $fill_y; } }); }); #### { my ($line, $char); BEGIN { ($line, $char) = (1, 0) } sub text_show { my ($text, $str) = @_; if (0 == index $str, "\r") { $str = substr $str, 1; $text->delete("$line.0", "$line.$char"); $char = 0; } $text->insert("$line.$char" => $str); if (-1 < index $str, "\n") { $line += $str =~ y/\n//; $char = length(substr $str, rindex $str, "\n") - 1; } else { $char += length $str; } $text->see("$line.$char"); } }