use strict;
use warnings;
use Tk;
use Tk::ProgressBar;

my ($progress, $percent_done, $mw);

$mw = MainWindow->new(-title => '     Beispiel ProgressBar     ');

$progress = $mw->ProgressBar(-width => 20,     # schmale Seite des Balkens
                             -from => 0,       # Anfangswert
                             -to => 100,       # Endwert
                             -blocks => 100,   # Unterteilt in wieviel Stufen
                             -gap => 4,        # Luecke zwischen den Stufen
                                               # Farbdefinitionen:
                             -troughcolor => '#FFFFFF', # Hintergrundfarbe
                             -colors => [0, 'green',    # Jeweils die Stufe
                                         50, 'yellow',  # und die Farbe ab
                                         80, 'red'],    # dieser Stufe
                             -variable => \$percent_done)
                       ->pack(-fill => 'x');


$mw->Button(-text => 'Go!', -command => \&doit)->pack(-side => 'bottom');

MainLoop; 

sub doit
  {
  for my $i (0 .. 1000) 
    { 
    $percent_done = $i/10;
    $mw->update;  # otherwise we don't see how far we are.
    }
  }