Ruby Application Archive contains several extensions that
provide Ruby with a graphical user interface (GUI), including
extensions for Tcl/Tk, GTK, OpenGL, and others.
The Tk extension is bundled in the main distribution and works on
both Unix and Windows systems. To use it, you need to have Tk
installed on your system. Tk is a large system, and entire books have
been written about it, so we won't waste time or resources by delving
too deeply into Tk itself, but instead concentrate on how to access Tk
features from Ruby. You'll need one of these reference books in order
to use Tk with Ruby effectively. The binding we use is closest to the
Perl binding, so you probably want to get a copy of
Tk works along a composition model---that is, you start off by
creating a container widget (such as a
) and then
create the widgets that populate it, such as buttons or labels.
When you are ready to start the GUI, you invoke
Tk engine then takes control of the program, displaying widgets and
calling your code in response to GUI events.