Re: Subject: Progress Bar question



On Mon, 22 Aug 2005 05:53:47 -0400 (EDT)

Date: Mon, 22 Aug 2005 03:48:09 +0300 (EEST)
From: Gergely Korodi <gergely korodi tut fi>
Subject: Progress Bar question

You need to set up a timer to control the progressbar.

#!/usr/bin/perl
use warnings;
use strict;
use Glib qw/TRUE FALSE/;
use Gtk2 '-init';

my $window = Gtk2::Window->new('toplevel');
$window->signal_connect( delete_event => sub { Gtk2->main_quit; } );
$window->set_border_width(10);
my $vbox = Gtk2::VBox->new( 0, 5 );
my $button = Gtk2::Button->new("Progress");

$button->signal_connect( clicked => \&cb1, $window );

$vbox->pack_start( $button, TRUE, TRUE, 0 );

my $progress = new Gtk2::ProgressBar;
my $fraction = 0.0;
$progress->set_fraction($fraction);
$vbox->pack_start( $progress, TRUE, TRUE, 0 );

$window->add($vbox);
$window->show_all;
Gtk2->main;
0;

#####################################################
sub cb1 {
  my $timer = Glib::Timeout->add (100,\&show_progress);
}

sub show_progress{
    $fraction += 0.01;
      if($fraction >= 1){return 0}  #stops timer
      $progress->set_fraction($fraction);
return 1;
}
__END__


-- 
I'm not really a human, but I play one on earth.
http://zentara.net/japh.html



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