use Tk; use Tk::ProgressBar; my $mw = MainWindow->new(); my $value = 1; $mw->Button(-text => "Add/Update!", -command => [\&addUpdateButtonPressed])->pack(); $progressBar = $mw->ProgressBar( -width => 16, -length => 400, -anchor => 'w', -from => 0, -to => 10, -blocks => 10, -gap => 0, -colors => [0, 'green', 50, 'yellow' , 80, 'red'], -variable => \$value )->pack(); MainLoop; sub addUpdateButtonPressed { while (1) { $value ++; $progressBar->update(); ($value < 10) ? sleep 1 : last; } }