#!perl -slw use strict; use threads; use threads::shared; ## A shared var to communicate progress between work thread and TK my $progress : shared = 0; sub work{ open PROC, 'perl -le"$|=1; print and select(undef,undef,undef,0.1) for 1 .. 1000" |' or die $!; while( ) { lock $progress; $progress = $_; } close PROC; } threads->new( \&work )->detach; require Tk::ProgressBar; my $mw = MainWindow->new; my $pb = $mw->ProgressBar()->pack(); my $repeat; $repeat = $mw->repeat( 100 => sub { # print $progress; $repeat->cancel if $progress == 100; $pb->value( $progress ) } ); $mw->MainLoop;