Hi all,
I write a small Ruby/Tk GUI and try to get the size of each widget.
But to my surprise that the returned values are all 0. I wonder why this
happens and what is the correct line/code to return the size of each
widget.
Thanks.
###############script################
require ‘tk’
hello=TkRoot.new do
title ‘hello’
minsize(400,400)
end
$lbl=TkLabel.new(hello) do
text ‘hello’
foreground ‘red’
place(:x=>15,:y=>15)
relief “groove”
end
$bt=TkButton.new(hello) do
text ‘hello world’
foreground ‘green’
place(:x=>15,:y=>55)
relief “groove”
command proc{
puts $lbl.width
puts $lbl.height
puts $bt.width
puts $bt.height
}
end
Tk.mainloop