#!/usr/bin/perl use Tk; use strict; require Tk::ProgressBar; require Tk::Button; my ( $mw, $progressBar, $cancelCalButton, $runCalButton, ); my $guiPid = $$; $mw = MainWindow->new(); $cancelCalButton = $mw->Button(-text=>"cancel")->pack(); $runCalButton = $mw->Button(-text=>"run",-command=>\&doit)->pack(); $progressBar = $mw->ProgressBar()->pack(); my $val = 0; $SIG{USR1} = sub { $val = 0; $progressBar->value(0); $mw->update(); $runCalButton->configure(-state=>"normal"); $cancelCalButton->configure(-state=>"disabled"); }; $SIG{USR2} = sub { $val++; $progressBar->value($val*10); $mw->update(); }; MainLoop; sub doit { my $calPid; $runCalButton->configure(-state=>"disabled"); $cancelCalButton->configure(-state=>"normal"); $mw->update; print "Failed to fork" if (!defined($calPid = fork())); return if ($calPid); for (1 .. 10) { $progressBar->value($_); kill('USR2',$guiPid); sleep(1) ; } # send the signal to main GUI to reconfigure the button states kill('USR1',$guiPid); kill('INT',$$); }
In reply to Re: Tk::Progressbar gives X Error
by SleepNot
in thread Tk::Progressbar gives X Error
by gri6507
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |