From: Justin Collins Date: 2008-02-23T02:13:03+09:00 Subject: Re: Ruby/Tk Isaac Toothyxdip wrote: > Ok i have a question how come when i press the button it adds one but > then it doesnt do it again? Does it have to be in some kind of loop? > > require 'tk' > number = 1 > hello = TkRoot.new do > title "Hello World" > minsize(400,400) > end > lbl = TkLabel.new() { justify 'center' > text "#{number}"; > pack('padx'=>5, 'pady'=>5, 'side' => 'top') } > TkButton.new() { > text "Add 1" > command proc { lbl.configure('text'=>"#{number + 1}") } > pack('side'=>'right', 'padx'=>10, 'pady'=>10) > } > Tk.mainloop > > Thanks > It is doing it. It changes the text to number + 1 (that is, 1 + 1) each time. If you actually want to change the variable, try command proc { lbl.configure('text'=>"#{number += 1}") } -Justin