You could also do it without a flag, using the ismapped method.#!/usr/bin/perl use warnings; use strict; use Tk; my $mw = tkinit; my $tl = $mw->Toplevel(-title=>"Stupid Program"); my $text = $tl->Text()->pack(); my $flag = 0; my $cancel_btn= $tl->Button(-text=>"Cancel", -command=> sub { $flag = 1; $tl->withdraw })->pack(-side =>'left', -expand=>1, -anchor => 'center'); + my $do_btn= $tl->Button(-text=>"Start", -command=> sub { while (<DATA>){ # process data # output to a text widget if($flag){last} $text->insert('end',"$_\n"); $text->update; $mw->after(1000); } })->pack(-side =>'left', -expand=>1, -anchor => 'center'); + MainLoop; __DATA__ 1 2 3 4 5 6 7 8 9 10
#!/usr/bin/perl use warnings; use strict; use Tk; my $mw = tkinit; my $tl = $mw->Toplevel(-title=>"Stupid Program"); my $text = $tl->Text()->pack(); my $cancel_btn= $tl->Button(-text=>"Cancel", -command=> sub { $tl->withdraw })->pack(-side =>'left', -expand=>1, -anchor => 'center'); + my $do_btn= $tl->Button(-text=>"Start", -command=> sub { while (<DATA>){ # process data # output to a text widget if(! ismapped $tl){last} $text->insert('end',"$_\n"); $text->update; $mw->after(1000); } })->pack(-side =>'left', -expand=>1, -anchor => 'center'); + MainLoop; __DATA__ 1 2 3 4 5 6 7 8 9 10
In reply to Re: $widget->withdraw
by zentara
in thread $widget->withdraw
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |