Play with this
#!/usr/bin/perl -- use strict; use warnings; use Tk; use Tk::WidgetDump; use Tk::ObjScanner; my %ons; my $mw = tkinit(); for (1 .. 3) { my $goner = $_; $ons{$_} = $mw->Button( -text => "B $_", -command => sub { delete($ons{$goner})->destroy; ## this works, proper closu +re #~ delete($ons{$_})->destroy; ## this doesnt, $_ is alias } )->pack; } $mw->WidgetDump; ## before scan_object Tk::ObjScanner::scan_object( { mw => $mw, ons => \%ons } ); ## after W +idgetDump MainLoop();
In reply to Re^3: Clearing anonymous Tk widgets
by Anonymous Monk
in thread Clearing anonymous Tk widgets
by murrayn
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |