Message-ID: <89ddcaa365b83fbdde7c6fbaca328792@ruby-forum.com>
> I'm not sure how to start off translating all this code justt see a bit
> might help, anyone know how to trans. this?
sorry hit enter =(! ok, this is the code!.....: #!
/usr/local/bin/wish8.1 button .b -text 0 -command {.b config -text [expr
[.b cget -text]+1]}
pack .b ;#RS
Follwoings are some of the examples.
Please see also
<http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/138653>\.
-----<ex.1>---------------------------------------------
b = TkButton.new(:text=>'0', :command=>proc{b.text = b.text.to_i + 1}).pack
···
From: Erik Boling <schmode93@yahoo.com>
Subject: Re: Ruby/Tk
Date: Sun, 2 Dec 2007 08:04:46 +0900
--------------------------------------------------------
-----<ex.2>--------------------------------------------
b = TkButton.new('text'=>'0', 'command'=>proc{b.text = b.text.to_i + 1}).pack
--------------------------------------------------------
-----<ex.3>---------------------------------------------
b = TkButton.new(:text=>'0', :command=>proc{b.text(b.text.to_i + 1)}).pack
--------------------------------------------------------
-----<ex.4>---------------------------------------------
b = TkButton.new(:text=>'0', :command=>proc{b[:text] = b.text.to_i + 1}).pack
--------------------------------------------------------
-----<ex.5>---------------------------------------------
b = TkButton.new(:text=>'0', :command=>proc{b['text'] = b.text.to_i + 1}).pack
--------------------------------------------------------
-----<ex.6>---------------------------------------------
TkButton.new(:text=>'0'){|b|
command{b.text = b.text.to_i + 1}
}.pack
--------------------------------------------------------
-----<ex.7>---------------------------------------------
TkButton.new(:text=>'0'){
command{self.text = self.text.to_i + 1}
}.pack
--------------------------------------------------------
-----<ex.8>---------------------------------------------
TkButton.new(:text=>'0'){
command{text(text.to_i + 1)}
}.pack
--------------------------------------------------------
-----<ex.9>---------------------------------------------
TkButton.new{
text 0
command{text(text.to_i + 1)}
pack
}
--------------------------------------------------------
-----<ex.10>--------------------------------------------
cnt = 0
b = TkButton.new(:text=>cnt, :command=>proc{b.text = (cnt += 1)}).pack
--------------------------------------------------------
-----<ex.11>--------------------------------------------
TkButton.new{
cnt = 0
text cnt
command{text(cnt+=1)}
pack
}
--------------------------------------------------------
-----<ex.12>---------------------------------------------
v = TkVariable.new(0)
TkButton.new(:textvariable=>v, :command=>proc{v.numeric += 1}).pack
--------------------------------------------------------
--
Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)