#!/usr/bin/winperl use strict; use warnings; use Tk; use Tk::ProgressBar; my $mw = MainWindow->new(); my $prog = $mw->ProgressBar( -length => 200, # Actually width -width => 20, # Actually height -gap => 0, -value => 0, -colors => [0, 'navy'], )->pack(-pady => 5, -padx => 5), my @ints = (1 .. 100); for my $int (@ints) { # Set the new value of the progress bar to # the old value ($prog->value) plus one. $prog->value($prog->value + 1); tksleep($mw, 10); } # Like sleep, but actually allows the display to be # updated, and takes milliseconds instead of seconds. sub tksleep { my $mw = shift; my $ms = shift; my $flag = 0; $mw->after($ms, sub { $flag++ }); $mw->waitVariable(\$flag); }