Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Perl/Tk widget removal problem...

by converter (Priest)
on Aug 29, 2003 at 20:04 UTC ( #287822=note: print w/ replies, xml ) Need Help??


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


Comment on Re: Perl/Tk widget removal problem...
Select or Download Code
Re^2: Perl/Tk widget removal problem...
by ig (Vicar) on Feb 19, 2011 at 05:44 UTC

    More than 10 years later (Tk/Widget.pm version 4.035) and the bug (inconsistency between documentation and implementation) still exists. Fortunately, your patch still works, except for the line numbers.

    I have tested minimally and have no idea why this method is not supported. Maybe they have left it out for good reason that I am, thus far, blissfully unaware of.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://287822]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (7)
As of 2014-07-31 22:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (254 votes), past polls