Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Hiding and Showing part of the Tk GUI

by Ace128 (Hermit)
on Jul 19, 2005 at 02:05 UTC ( [id://475947]=perlquestion: print w/replies, xml ) Need Help??

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

Hey Monks,

Before I go to the question, I must say that this place really rocks! So many knowledgable people! Little different "forum" layout, but it works fine.

Question:
Ok, say I made this nice GUI in Tk, where I have created several Tk::Frame's (Tk::LabFrame) to seperate the GUI in different sections. Now, I wanna be able of hiding/showing these frames how I choose (along with the stuff on the frames)! Ideas how to do this? Destroy destroys... I want something like $frame->hide(), and $frame->show(); and natrually, the whole GUI is resized...

Ideas? :)

Thanks,
Ace

Replies are listed 'Best First'.
Re: Hiding and Showing part of the Tk GUI
by mawe (Hermit) on Jul 19, 2005 at 04:53 UTC
    Hi!

    You could use packForget():

    use Tk; my $top = new MainWindow; my $frame = $top->Frame(); $frame->Label(-text=>"Can you see me?")->pack(); $top->Button(-text=>"Hide",-command=>sub{$frame->packForget()})->pack( +); $top->Button(-text=>"Show",-command=>sub{$frame->pack()})->pack(); $frame->pack(); MainLoop();
    packForget() removes the widget from the packing order. If you repack it later, it appears at the end of the packing order. You can get the pack configuration with @conf = $frame->packInfo(). The same is possible with grid.

    Regards, mawe

      Lovely! Works like a charm! This is why I love Tk so much! :) So damn neat, and easy to do otherwise seemable tricky things.
Re: Hiding and Showing part of the Tk GUI
by waswas-fng (Curate) on Jul 19, 2005 at 02:20 UTC
    have you tried changing the container's size to 0 and then repacking?


    -Waswas
      Wow, now that is smart :) (why didnt I just think of that?) No.. Gotta try that...

      Update: Um, doesnt seem to work... $frame->geometry("=0x0+0+0");... damn.. would be neat else...
      wrong # args: should be "winfo geometry window" at C:\Perl\site\lib/Tk/Submethod.pm

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://475947]
Approved by GrandFather
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (None)
    As of 2024-04-25 01:13 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found