From: Bart Masschelein Date: 2005-08-31T03:49:42+09:00 Subject: Tk Label and instance variables Hello all, Below is a small piece of test code for a label using Tk. I try to set a label using an instance variable, and one using a local variable. The label with the local variable shows correctly in the window, the one with the instance variable doesn't. I get a warning: instance variable @value not initialized. Although the puts in between proves differently. What is the magic between all of this? I tried adding value to attr_reader, but that didn't solve anything. Not that I was expecting it to. As you probably can see, I come from a C/C++ background, and am probably missing some Ruby fundamentals to solve this. My collection of example scripts is rather small for the moment, and hence is also my experience. So any directions are welcome. gr.b. class LabelTest def initialize(value) @value = value end def run root = TkRoot.new { title "Label test" } puts @value TkLabel.new(root) do text "#{@value}" pack { padx 15 ; pady 15; side 'left' } end value2 = 200 TkLabel.new(root) do text "#{value2}" pack { padx 15 ; pady 15; side 'left' } end Tk.mainloop end end test = LabelTest.new(100) test.run