use strict; use Tk; use Tk::StatusBar; use itemDispatch; use doWork; # Subscribe to PROGRESS events... itemDispatch::Subscribe('PROGRESS', \&_updateProgress); my $PROGRESS = 0; my $INCREMENT = 5; my $mw = MainWindow->new(); $mw->Button( -text => 'Start', -command => # Publish a START event... sub{ doWork::StartWork($INCREMENT)})->pack(); my $sb = $mw->StatusBar(); $sb->addProgressBar( -length => 60, -from => 0, -to => 99, -variable => \$PROGRESS, ); MainLoop(); sub _updateProgress { my $progress = shift || die "Missing Progress\n"; print STDERR "Updating progress by $progress\n"; $PROGRESS += $progress; $mw->update; }