A
Alex DeCaria
The code below, which puts "Hello" in a label on press of a button,
works if the command for the button is { a.value = "Hello" }, but not if
it is { a = "Hello" }. I'm trying to understand "why", and can't find
anything on the ".value" method in in the Pragmatic Programmers' book on
Ruby.
Can someone explain why {a = "Hello"} won't work, and why I need to do
{a.value = "Hello"?}
Thanks in advance.
------------------------------------
require 'tk'
root = TkRoot.new.title("Example")
a = TkVariable.new
Labels = TkLabel.new(root) do
textvariable a
pack('side' => "top")
end
TkButton.new(root) do
text "Press"
command { a.value = "Hello" }
pack('side' => "top")
end
Tk.mainloop
works if the command for the button is { a.value = "Hello" }, but not if
it is { a = "Hello" }. I'm trying to understand "why", and can't find
anything on the ".value" method in in the Pragmatic Programmers' book on
Ruby.
Can someone explain why {a = "Hello"} won't work, and why I need to do
{a.value = "Hello"?}
Thanks in advance.
------------------------------------
require 'tk'
root = TkRoot.new.title("Example")
a = TkVariable.new
Labels = TkLabel.new(root) do
textvariable a
pack('side' => "top")
end
TkButton.new(root) do
text "Press"
command { a.value = "Hello" }
pack('side' => "top")
end
Tk.mainloop