From: Hidetoshi NAGAI Date: 2007-12-06T15:51:23+09:00 Subject: Re: Ruby/Tk From: Erik Boling Subject: Re: Ruby/Tk Date: Sun, 2 Dec 2007 08:04:46 +0900 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 . -------------------------------------------------- b = TkButton.new(:text=>'0', :command=>proc{b.text = b.text.to_i + 1}).pack -------------------------------------------------------- ------------------------------------------------- b = TkButton.new('text'=>'0', 'command'=>proc{b.text = b.text.to_i + 1}).pack -------------------------------------------------------- -------------------------------------------------- b = TkButton.new(:text=>'0', :command=>proc{b.text(b.text.to_i + 1)}).pack -------------------------------------------------------- -------------------------------------------------- b = TkButton.new(:text=>'0', :command=>proc{b[:text] = b.text.to_i + 1}).pack -------------------------------------------------------- -------------------------------------------------- b = TkButton.new(:text=>'0', :command=>proc{b['text'] = b.text.to_i + 1}).pack -------------------------------------------------------- -------------------------------------------------- TkButton.new(:text=>'0'){|b| command{b.text = b.text.to_i + 1} }.pack -------------------------------------------------------- -------------------------------------------------- TkButton.new(:text=>'0'){ command{self.text = self.text.to_i + 1} }.pack -------------------------------------------------------- -------------------------------------------------- TkButton.new(:text=>'0'){ command{text(text.to_i + 1)} }.pack -------------------------------------------------------- -------------------------------------------------- TkButton.new{ text 0 command{text(text.to_i + 1)} pack } -------------------------------------------------------- ------------------------------------------------- cnt = 0 b = TkButton.new(:text=>cnt, :command=>proc{b.text = (cnt += 1)}).pack -------------------------------------------------------- ------------------------------------------------- TkButton.new{ cnt = 0 text cnt command{text(cnt+=1)} pack } -------------------------------------------------------- -------------------------------------------------- v = TkVariable.new(0) TkButton.new(:textvariable=>v, :command=>proc{v.numeric += 1}).pack -------------------------------------------------------- -- Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)