Ruby/tk : hide TkFrame

hi, rubists.

quick question’s here.

I have two TkFrame instance on main panel and then I want to hide one
of them by some kinds of option(checkbutton or somelike that).

is there possible way to do this?

example)
require “tk”

f1 = TkFrame.new {
relief ‘sunken’
borderwidth 3
background “red”
padx 15
pady 20
pack(‘side’ => ‘left’)
}
f2 = TkFrame.new {
relief ‘groove’
borderwidth 1
background “yellow”
padx 10
pady 10
pack(‘side’ => ‘right’)
}

TkButton.new(f1) {
text ‘Button1’
command {print “push button1!!\n”}
pack(‘fill’ => ‘x’)
}
TkButton.new(f1) {
text ‘Button2’
command {print “push button2!!\n”}
pack(‘fill’ => ‘x’)
}
TkButton.new(f2) {
text ‘Quit’
command ‘exit’
pack(‘fill’ => ‘x’)
}

Tk.mainloop

How can I hide frame f2?

From: Jun Y. Kim [email protected]
Subject: ruby/tk : hide TkFrame
Date: Wed, 1 Jul 2009 14:11:58 +0900
Message-ID: [email protected]

I have two TkFrame instance on main panel and then I want to hide one
of them by some kinds of option(checkbutton or somelike that).

What is your purpose?
Probably, most suitable way depends on it.

For example, f2.unpack removes f2 on the window.
And then, if you want to keep the window size,
you’ll need call f2.winfo_parent.pack_propagate(false) before f2.upnack.
if your purpose is to make the QUIT button disable,
you should use ‘state’ option of button widgets.

What do you want really?