------ art_6946_449978.1144859459733 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Oh sorry I meant to say that it returns 1. If I click the button 29 times, the label shows 30, but the value that was puts'ed is still 1. 2006/4/12, Hidetoshi NAGAI <nagai / ai.kyutech.ac.jp>: > > From: "Jeppe Jakobsen" <jeppe88 / gmail.com> > Subject: Re: Q about tk buttons > Date: Wed, 12 Apr 2006 17:41:38 +0900 > Message-ID: <99b4ad3b0604120141ha09eaacoa4b3a30bf18f9285 / mail.gmail.com> > > Thanks that kind of worked, but how come that the variable still returns > 0, > > when I add > > > > puts var.value > > > > to my code, just before Tk.mainloop? > > ??? > > ---< var-test1.rb >---------------------------------------- > require "tk" > var = TkVariable.new(0) #defining variable > var += 1 #making it a fixnum and adding 1 > > root = TkRoot.new() > > label = TkLabel.new(:text=> var).pack() > > button = TkButton.new(:text=> "Button", :command=>proc{var += 1}).pack() > > puts var.value > > Tk.mainloop > ----------------------------------------------------------- > > $ /usr/local/bin/ruby -v > ruby 1.8.4 (2006-04-06) [i686-linux] > $ /usr/local/bin/ruby var-test1.rb > var-test1.rb:11: undefined method `value' for 1:Fixnum (NoMethodError) > > > ---< var-test2.rb >---------------------------------------- > require "tk" > var = TkVariable.new(0) > var.numeric += 1 > label = TkLabel.new(:textvariable=>var).pack() > button = TkButton.new(:text=> "Button", :command=>proc{var.numeric += > 1}).pack() > puts var.value > Tk.mainloop > ----------------------------------------------------------- > > $ /usr/local/bin/ruby -v > ruby 1.8.4 (2006-04-06) [i686-linux] > $ /usr/local/bin/ruby var-test2.rb > 1 > $ > > -- > Hidetoshi NAGAI (nagai / ai.kyutech.ac.jp) > > -- "winners never quit, quitters never win" ------ art_6946_449978.1144859459733--