Progress bar help



I am having trouble getting a progress bar to work properly.  I am
preparing to write a backup program, but as of now I am just messing
around.

I can create the progress bar and I can make it so that whenever I click
a button, it increments toward 100% like it is supposed to.  However
when I go and try to have the function automatically increment itself
every second toward 100%, the bar does nothing until the function
completes and it immediate jumps to 100%.  I am sure I am just missing
something simple, what I think are relevant portions of code follow
below.

Can someone also explain to me what pluse does?  I think I know but I am
not sure.

thanks,

Dan

my $buttonb=Gtk2::Button->new('Backup');
$obox->pack_start($buttonb,FALSE,FALSE,0);
$buttonb->signal_connect(clicked => \&progresstest);

$progressbar = Gtk2::ProgressBar->new();
$progressbar->pulse();
$progressbar->set_fraction(0);
$progressbar->set_pulse_step(1/20);
$progressbar->set_orientation('left_to_right');
$progressbar->set_text("0%");


$obox->pack_start($progressbar,TURE,TURE,0);


sub progresstest {
  $progresssbar->{activity_mode}=not $progressbar->{activity_mode};
  $count=0;
  while($count<20){
    sleep 1;
    $count++;
    newstatus($context_id,$count/20);
    $progressbar->set_text(int($count/20*100)."%");
    $progressbar->set_fraction($count/20);
    #$progressbar->show;
    $progressbar->pulse();
  }
  
}




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