Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

How do i delete a widget:
for($i=0;$i<10;++$i) { $mw->Button(-relief => 'flat', -background =>"#FFFFFF",-width => 2, -h +eight => 2)->pack(); }
how can i delete them from the $mw widget

Replies are listed 'Best First'.
Re: Tk question...
by shmem (Chancellor) on Jun 07, 2009 at 19:33 UTC

    Use $button->DESTROY to get rid of it.

    The call to $mw->Button() returns a Button reference. You need that for the DESTROY call.

    use Tk; $mw = MainWindow->new; for($i=0;$i<10;++$i) { my $b = $mw->Button( -relief => 'flat', -background =>"#FFFFFF", -width => 2, -height => 2, -text => "B $i", )->pack; $b->configure(-command => [ $b, 'DESTROY' ]); } MainLoop; __END__

    The above code destroys a button when you click on it.