Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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


In reply to Re: Perl/Tk widget removal problem... by converter
in thread Perl/Tk widget removal problem... by jdtoronto

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (2)
As of 2024-04-25 20:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found