Need to check the license of this document.
In any case, reproduction in verbatim is allowed.
So you found Ruby and liked it. Now you need a GUI
toolkit. Be warned: gtk, Qt and fox have Ruby bindings
as well. May be those suit your needs better.
This tutorial is aimed at people that want to use Tk as toolkit with
Ruby. It does not really matter whether you are very proficient in Ruby or with
toolkits. Examples may overwhelm the novice sometimes, but each line is
explained. Step over it and come back in a later stage. The small differences
in those lines provide a wealth of information for the more experienced
Note: This is a work in progress. Mail comments
to Kero. Or edit directly
on The wiki version (which will, at
some point, make this version obsolete).
A few reasons to use Tk:
A few reasons not to use Tk
- Tk is supported in many places (though others are definitely catching up),
- Tk may look small or simple, but is very powerful. Of course it can do all
basics, like any toolkit, but some things are done in a very simple way,
- Its canvas has some very nice features for selecting and manipulating
objects (like lines and curves) on it. It can even dump its content in a
- Tk has a few prebuilt windows like a color chooser and dialog,
- Can use many Tk extensions from Ruby.
- In a certain environments, other toolkits will look better (Gtk in Gnome,
Qt under KDE),
- You are addicted to an IDE and demand you can build your UI with
mouseclicks (or may be that's actually a reason to look at the building blocks
and read on :-)
If you installed Ruby yourself, possibly the Tk bindings do not work. First,
make sure you have tcl/tk installed. Then look
Hello, World! How to start Tk from Ruby and the first
Combining Simple Widgets, building a small GUI,
Binding Events, reacting on user input,
Combining More Widgets, building a behaving
Menus, in its many appearances
Canvas, the powerful draw-anything-on
Make things look Beautiful
More information Places where you want to look,
too; before, during and after this course.