#!perl use strict; use warnings; use Tk; use Tk::Button; use Tk::ProgressBar; my $mw = MainWindow->new(); my $progress; my $toggle = 0; my @colours = ( [ 0 => q{#ff0000}, 30 => q{#00ff00}, 60 => q{#0000ff} ], [ 0 => q{#ffff00}, 30 => q{#00ffff}, 60 => q{#ff00ff} ], ); my $pb = $mw->ProgressBar( -width => 20, -length => 200, -colors => $colours[$toggle], -variable => \$progress, )->pack(); $mw->Button(-text => q{Jump WITH Change}, -command => sub { $progress ||= 0; $progress = ($progress + 10) % 110; $toggle ^= 1; $pb->configure(-colors => $colours[$toggle]); Tk::ProgressBar::_layoutRequest($pb, 1); } )->pack(); $mw->Button(-text => q{Jump NO Change}, -command => sub { $progress ||= 0; $progress = ($progress + 10) % 110; $toggle ^= 1; $pb->configure(-colors => $colours[$toggle]); } )->pack(); $mw->Button(-text => q{Exit}, -command => sub { exit })->pack(); MainLoop;