Re: ProgressBar set_text



On Tue, Jul 17, 2007 at 10:16:30AM +0200, Jeffrey Ratcliffe wrote:
I have a ProgressBar tracking a forked process below. There is
presently a debugging line

print "$1 $2\n";

With this left in, the text in the ProgressBar is updated OK. Without
the print statement, the text is not updated.

What is going on?
[...]
sub sig_child {
  my $pid = wait;
  if ($pid >= 0) {
  delete $helperTag{$pid};
 }
}
[... other indentation mistakes ...]

Oh, for the love of God, if you want other people to look at your code
then please make it readable. That *includes* "having proper
indentation". Having to look at such messy code just made my eyes bleed.

That being said,

   if ($condition & 'in') { # bit field operation. >= would also work
    my $line = <$reader>;
    if ($line =~ /(\d*\.?\d*)(.*)/) {
print "$1 $2\n";
     $pbar->set_fraction($1);
     $pbar->set_text($2);
    }
   }

directly using values which you extract using a regex like that has
issues with glib (it wants to have modifiable variables, which these
things aren't). Try assigning them to temporary variables before going
on:

if($line =~ /(\d*\.?\d*)(.*)/) {
        my $fraction=$1;
        my $text=$2;
        $pbar->set_fraction($fraction);
        $pbar->set_text($text);
}

Also, I don't think fractional values are allowed for a progress bar.

-- 
Wouter Verhelst
NixSys BVBA
Louizastraat 14, 2800 Mechelen
T: +32 15 27 69 50 / F: +32 15 27 69 51 / M: +32 486 836 198



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]