> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On 
> Behalf Of Don VanSyckel
> Sent: Saturday, June 09, 2007 7:13 PM
> To: [email protected]
> Subject: Turn off the Progess bar
> 
> I have a small program that copies some file and uses the 
> Progress Bar on the bottom of the TK window to display 
> progress.  When the copy is done I'd like to remove the 
> Progress Bar and pop up a second windows saying copy done 
> with an 'OK' to close it.
> 
> I'm having problems figuring this out.  Any suggestions?

You can either destroy your progressbar after you are finished with it, or
if you intend to use it again, then just do a packForget on it.

$pbar->destroy; #permanent

Or 

$pbar->packForget; #object still exists for re-use (via 'pack'ing it again)

Then to pop up a box saying done, you can either use a Dialog or messageBox.

Here is a fully working sample:
########################################
use Tk;
use Tk::Dialog;
use Tk::ProgressBar;
use strict;
my $percent=0;

my $mw=new MainWindow;
my $text=$mw->Scrolled('Text',-scrollbars=>'se')->pack;
my $button =$mw->Button(
  -text=>'Something that takes some time',
  -command=>\&doSomething)->pack;
my $pb=$mw->ProgressBar(
  -variable=>\$percent,
  -width=>20,
  -length=>200)->pack;
my $dialog = $mw->Dialog(
  -popover=>$mw,
  -bitmap=>'info',
  -text=>'Task completed !',
  -buttons=>['Ok']);
MainLoop;

sub doSomething
{
   for(1..10){
      $percent = $_ * 10;
      $text->insert('end',"$percent percent done\n");
      $mw->update;
      $mw->after(500);
  }
   $text->insert('end', "Progressbar will delete in 5 seconds\n");
   $text->update;
   $mw->after(5000,\&destroyPB);
}

sub destroyPB {
  $pb->destroy;
  $dialog->Show;
  $button->configure(-state=>'disabled');
}
__END__
--
Jack




_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to