in reply to Re: Updating the Tk::ProgressBar live
in thread Updating the Tk::ProgressBar live

Well, the problem isnt that its not working. Its the gfx that aint updating _while_ working! Code is something like this: :)
$mw->Label(-text => "Path:")-> grid( -row => 0, -column => 0, -sticky => 'w'); my $pathEntry = $mw->Entry(-width => 50, -textvariable => \$fu +ll_path)-> grid( -row => 0, -column => 1, -sticky => 'w'); $mw->Button(-text => "Browse...", -command => sub {print $full +_path})-> grid( -row => 0, -column => 2, -sticky => 'n'); $mw->Button(-text => "Add/Update!", -command => [\&addUpdateBu +ttonPressed])-> grid( -row => 1, -column => 1, #-columnspan => 3, -sticky => 'n'); $mw->Label(-text => "Progress:")-> grid( -row => 2, -column => 0, -sticky => 'w'); $progressLabel = $mw->Label(-text => "0 / Unknown")-> grid( -row => 2, -column => 1, -sticky => 'n'); my $variable = 24; $progressBar = $mw->ProgressBar( -width => 16, -length => 400, -anchor => 'w', -from => 0, #-to => 100, -blocks => 10, -gap => 0, -colors => [0, 'green', 50, 'yellow' , 80, 'red'], -variable => \$statics{'files'} )-> grid( -row => 3, -column => 0, -columnspan => 3, -sticky => 'n'); &centerWindow($mw, 410, 100); $pathEntry->focus; MainLoop; sub addUpdateButtonPressed { print "Getting statics from: " . $full_path . " ...\n"; my $total_files = &countFilesTotally($full_path); print "Files found: " . $total_files . "\n"; $statics{'files'} = 0; $progressLabel->configure(-text => "0 / " . $total_files); $progressBar->configure(-to => $total_files); $progressBar->repeat(500, sub {$progressBar->update}); #threads->create("recursive", $full_path); &recursive($full_path); } sub recursive { my $dir = shift; .. do alot of stuff ... }

Replies are listed 'Best First'.
Re^3: Updating the Tk::ProgressBar live
by davidrw (Prior) on Sep 06, 2005 at 12:21 UTC
    What if you try to explictily update it with $progressBar->value( $statics{'files'} ) in your recursive loop instead (and remove the -variable line from the $mw->ProgressBar() call)? Could be that it's the linked scalar wthat's not working properly (i've heard of issues like that before, too)..

    Side question -- i don't see a "my" in front of $progressBar .. are you not using strict/warnings, or just declaring some stuff at the top c-style?