http://qs321.pair.com?node_id=287822


in reply to Perl/Tk widget removal problem...

I was just poking around in the Tk source (I think I'll be able to grok Lex Rex before I understand the Tk source) and it looks like there's no support for gridRemove in the code where I'd expect to find it. Maybe it was removed, or never added in the first place?

In Tk/Widget.pm (I THINK this is part of the dispatch mechanism):

sub grid { local $SIG{'__DIE__'} = \&Carp::croak; my $w = shift; if (@_ && $_[0] =~ /^(?:bbox|columnconfigure|configure|forget|info|lo +cation|propagate|rowconfigure|size|slaves)$/x) { my $opt = shift; Tk::grid($opt,$w,@_); } else { # Two things going on here: # 1. Add configure on the front so that we can drop leading '-' Tk::grid('configure',$w,@_); # 2. Return the widget rather than nothing return $w; } }

Note that a direct call to &Tk::grid with the 'remove' argument works:

$ perl -MTk -e '$m=tkinit; $f=$m->Frame->pack; $b=$f->Button(-text=>"F +oo")->grid; $m->after(750,sub{Tk::grid("remove",$b)}); MainLoop'

This patch to Tk/Widget.pm version 3.080 (Tk 800.024) seems to fix the problem for me:

--- Widget.pm.orig 2003-08-29 14:53:46.000000000 -0500 +++ Widget.pm 2003-08-29 14:45:14.000000000 -0500 @@ -61,7 +61,7 @@ use Tk::Submethods( 'grab' => [qw(current status release -global)], 'focus' => [qw(-force -lastfor)], 'pack' => [qw(configure forget info propagate sl +aves)], - 'grid' => [qw(bbox columnconfigure configure for +get info location propagate rowconfigure size slaves)], + 'grid' => [qw(bbox columnconfigure configure for +get info location propagate remove rowconfigure size slaves)], 'form' => [qw(check configure forget grid info s +laves)], 'event' => [qw(add delete generate info)], 'place' => [qw(configure forget info slaves)], @@ -1060,7 +1060,7 @@ { local $SIG{'__DIE__'} = \&Carp::croak; my $w = shift; - if (@_ && $_[0] =~ /^(?:bbox|columnconfigure|configure|forget|info|l +ocation|propagate|rowconfigure|size|slaves)$/x) + if (@_ && $_[0] =~ /^(?:bbox|columnconfigure|configure|forget|info|l +ocation|propagate|remove|rowconfigure|size|slaves)$/x) { my $opt = shift; Tk::grid($opt,$w,@_);

converter