2004-05-01 12:09:54 -04:00
|
|
|
#!/usr/bin/env ruby
|
|
|
|
require 'tk'
|
|
|
|
|
|
|
|
TkLabel.new(:text=>"Please click the bottom frame").pack
|
|
|
|
|
2009-03-05 22:56:38 -05:00
|
|
|
f = TkFrame.new(:width=>400, :height=>100, :background=>'yellow',
|
2004-10-11 00:51:21 -04:00
|
|
|
:relief=>'ridge', :borderwidth=>5).pack
|
2004-05-01 12:09:54 -04:00
|
|
|
|
|
|
|
# TkPack.propagate(f, false) # <== important!!
|
|
|
|
f.pack_propagate(false) # <== important!!
|
|
|
|
|
|
|
|
list = (1..3).collect{|n|
|
|
|
|
TkButton.new(f, :text=>"button#{'-X'*n}"){
|
|
|
|
command proc{
|
|
|
|
puts "button#{'-X'*n}"
|
|
|
|
self.unpack
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
list.unshift(nil)
|
|
|
|
|
|
|
|
f.bind('1', proc{
|
2004-10-11 00:51:21 -04:00
|
|
|
w = list.shift
|
|
|
|
w.unpack if w
|
|
|
|
list.push(w)
|
|
|
|
list[0].pack(:expand=>true, :anchor=>:center) if list[0]
|
2004-05-01 12:09:54 -04:00
|
|
|
})
|
|
|
|
|
|
|
|
Tk.mainloop
|