#!/usr/bin/perl use strict; use Tk; use Tk::ProgressBar; my $mw=MainWindow->new; my $percent; my $pb=$mw->ProgressBar( -height => 0, -width => 20, -length => 100, -colors=>[0,'blue'], -blocks=>100, )->pack; my $btn=$mw->Button( -command => \&show_progress, -text => 'Run program', )->pack; MainLoop; sub show_progress{ for (1..100) { $percent=rand(100); $pb->value($percent); } } #### #!/usr/bin/perl use strict; use Tk; my $mw=MainWindow->new; my $percent; my $pb= $mw->Label( -bg => 'white', -fg => 'blue', -width => 60, -justify => 'left', -anchor => 'w', )->pack(); my $label1 = $mw->Label( -textvariable=> \$percent, )->pack(); my $timer = $mw->repeat(10,\&show_progress); MainLoop; sub show_progress{ $percent += 1; if($percent >= 100){$percent = 0} my $str = '|' x $percent; $pb->configure(-text => $str ); }