Ruby/TK packForget method

Is there a Ruby/TK equivalent to the Perl/TK packForget or gridForget
methods, which will remove a widget from display, but doesn’t destroy
the widget?

On Mar 5, 2007, at 10:24 AM, Alex DeCaria wrote:

Is there a Ruby/TK equivalent to the Perl/TK packForget or gridForget
methods, which will remove a widget from display, but doesn’t destroy
the widget?

The following example shows how ‘TkGrid.forget’ can cause some
buttons to disappear.

# Clicking on the "four" button causes the "four" and "five" buttons to # disappear.

require ‘tk’

DEBUG = []

begin
root = TkRoot.new {title ‘Tk Button Grid’}

lbls = ["one", "two", "three", "four", "five"]
btns = lbls.collect do |lbl|
   TkButton.new(root, "text"=> lbl, "command"=>lambda { Tk.bell })
end
btns[0, 3].each_with_index do |b, i|
   b.grid("row"=>0, "column"=>2*i, "columnspan"=>2)
end
btns[3, 2].each_with_index do |b, i|
   b.grid("row"=>1, "column"=>3*i, "columnspan"=>3, "sticky"=>"ew")
end
btns[3].command = lambda { TkGrid.forget(*btns[3, 2]) } # <= *******

quit_btn = TkButton.new(root) {
   text "Exit"
   command { root.destroy }
}
quit_btn.grid("row"=>2, "column"=>2, "columnspan"=>2,

“sticky”=>“ew”)

# Set window geometry.
min_w, min_h = 200, 95
root.minsize(min_w, min_h)
# Initial placement is top-center of screen.
root_x = (root.winfo_screenwidth - min_w) / 2
root.geometry("#{min_w}x#{min_h}+#{root_x}+50")

# Set resize permissions.
root.resizable(false, false)

# Make Cmnd+Q work as expected on OS X.
root.bind('Command-q') { Tk.root.destroy }

Tk.mainloop

ensure
puts DEBUG unless DEBUG.empty?
end

I imagine ‘TkPack.forget’ will work for packed widgets, but I have
not actually tried it.

Regards, Morton