Ruby/Tk

I have been looking for a good ruby GUI, and TK seems to be easiest

for me. I am quite new to programing in general, so bare with me if i’m
using the wrong “wordage” for things. I have been creating simple
programs, i.e basic skills math tests. But i have gotten bored/ annoyed
of cmd prompt. I was wondering does anyone know of any good tutorials
on how to program w/ TK. I have found some, but they are all very basic
and only go as far as explaining how to put buttons and text on the
window. I was trying to get my GUI more active like being able to
output and input information. Perhaps there is a better choice for a
Ruby GUI that someone might recommend that has more extensive easier
tutorials?
Thanks for the help :)!

On Nov 30, 2007, at 12:04 AM, Erik B. wrote:

and only go as far as explaining how to put buttons and text on the
window. I was trying to get my GUI more active like being able to
output and input information. Perhaps there is a better choice for a
Ruby GUI that someone might recommend that has more extensive easier
tutorials?

AFAIK there isn’t anything much more than introductory material
available in English on-line for Ruby/Tk. It’s really too bad because
Ruby/Tk provides a broad and deep range of GUI capabilities. After I
(rather quickly) reached the limitations of the available tutorials,
I turned to

<http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8/ext/tk/
sample/>

This is not a tutorial but a repository of example code. I have
learned much from studying these examples. I recommend you take a
look at them. Also, if you have a question about a specific Ruby/Tk
element you can post it here. I’ll answer it if I can. But more to
the point, NAGAI Hidetoshi (the implementor/maintainer of Ruby/Tk)
often answers such question, and his answers are always illuminating.
I have learned a great deal from them.

Regards, Morton

Tk started off as the graphical tool kit for a scripting language
called Tcl/Tk. I have a strong feeling that once you grasp the basics
of Ruby/Tk you can get some good ideas about how to use it by searching
for stuff that describes what you want to do at
http://wiki.tcl.tk (the Tcl/Tk) wiki.

You’ll need to translate the Tcl code that you see there to the
Ruby/Tk idioms but Tcl/Tk is pretty easy to read most of the time.

Ron F. wrote:

You’ll need to translate the Tcl code that you see there to the
Ruby/Tk idioms but Tcl/Tk is pretty easy to read most of the time.

I’m not sure how to start off translating all this code justt see a bit
might help, anyone know how to trans. this?

Erik B. wrote:

Ron F. wrote:

You’ll need to translate the Tcl code that you see there to the
Ruby/Tk idioms but Tcl/Tk is pretty easy to read most of the time.

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

From: Erik B. [email protected]
Subject: Re: Ruby/Tk
Date: Sun, 2 Dec 2007 08:04:46 +0900
Message-ID: [email protected]

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

-----<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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs