# Ruby/tk : hide TkFrame

**URL:** <https://www.ruby-forum.com/t/ruby-tk-hide-tkframe/171369>\
**Category:** Ruby\
**Created:** [July 1, 2009, 7:14am UTC](https://www.ruby-forum.com/t/ruby-tk-hide-tkframe/171369 "2009-07-01T07:14:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jun\_YSKim](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/a587f6/32.png) [@Jun\_YSKim](https://www.ruby-forum.com/u/Jun_YSKim)\
**Post date:** [July 1, 2009, 7:14am UTC](https://www.ruby-forum.com/t/ruby-tk-hide-tkframe/171369/1 "2009-07-01T07:14:24Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Jun\_YSKim](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/a587f6/32.png) [@Jun\_YSKim](https://www.ruby-forum.com/u/Jun_YSKim)\
**Post date:** [July 1, 2009, 11:10am UTC](https://www.ruby-forum.com/t/ruby-tk-hide-tkframe/171369/2 "2009-07-01T11:10:37Z")

</div>

From: Jun Y. Kim [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Subject: ruby/tk : hide TkFrame  
Date: Wed, 1 Jul 2009 14:11:58 +0900  
Message-ID: [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

> 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?
