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

Dear Monks

I would like to know if there is a better way to make widgets disappear than painting a canvas or something else over them. I look for some methods like Hide, but the Text widgets does not seem to have such a thing...

Thanks for your help in advance, as always.

Claire

Replies are listed 'Best First'.
Re: making widgets disappear
by merlyn (Sage) on Aug 01, 2005 at 06:22 UTC
    Is this about Tk? In the past, you've asked questions about Tk, but there are many places where "widgets" can mean something. Be sure you make that clear in future questions.

    Presuming it's about Tk, you can make a widget disappear simply by telling the geometry manager (Pack, Place, Grid, etc) to "forget" the item. If there's no geometry manager managing it, then it doesn't appear on the screen.

    -- Randal L. Schwartz, Perl hacker
    Be sure to read my standard disclaimer if this is a reply.

Re: making widgets disappear
by zentara (Cardinal) on Aug 01, 2005 at 11:08 UTC
    A simple example:
    #!/usr/bin/perl use warnings; use strict; use Tk; my $top = new MainWindow; my $txt = $top->Scrolled("Text")->pack; $top->Button(-text => "packForget", -command => sub{ my @w = $top->packSlaves; foreach (@w) { $_->packForget; } })->pack(); $top->Button(-text => "Exit", -command => sub {exit})->pack; MainLoop; __END__

    I'm not really a human, but I play one on earth. flash japh