Of Ruby GUI bindings, the Tk binding is the oldest; it is widely available and still more or less the default toolkit for GUI programming with Ruby. Nevertheless, currently there exists no comprehensive manual for Ruby/Tk; the Ruby book recommends inferring Ruby/Tk usage from the Perl/Tk documentation.
The current Ruby "PickAxe book" has a chapter on Ruby/Tk.
- There’s a pretty good tutorial www.tutorialspoint.com/ruby/ruby_tk_guide.htm .
- There are some pleasantly looking tutorials at tkdocs.com (it’s not really Tk’s official site).
- After having introducted yourself to the concepts of Tk you should also be able to read TclTk’s official reference (this is also available as man pages on Unix or a CHM file on Windows).
You may also be able to comfortably read PerlTk’s documentation as the Ruby bindings are said to be modeled after Perl’s.
Look and FeelEdit
The “look and feel” of your Tk application depends on the version of the Tk library your Ruby interpreter is linked against:
- Tk 8.4 and below is notorious for its “ugly” look. The widgets have the outdated Motif look and feel, and, on Unix-based systems, bitmap fonts are used.
If the Tk toolkit isn’t already installed on your system, you’ll have to install it. You may use your system’s “package manager” for this.
If you built Ruby before having installed the Tk dev package, it’s likely that it was built without Tk built in. For 1.9 versions you might be able to get away with installing it as a gem but your best bet is to install the tk dev package and reinstall Ruby so that it builds with the Tk bindings.
By default the “old” one click installer has the Tk binaries, however you’ll still need to install the Tk toolkit from ActiveState .
There’s a precompiled gem which should work out-of-the-box: tk-win.
It includes sources and libraries directly from Hidetoshi NAGAI. It’s Ruby 1.9 only.
The hope is that future versions of rubyinstaller will come with the binaries built in, then the above work-arounds won’t be necessary.
A few more gui toolkits are compared here.
- The ActiveState package for Windows, mentioned above, contains the documentation as a CHM file.
- “on X-Window systems”, to be exact.
- The Tile theming engine can be installed on older Tk 8.x libraries as well.
- Though you may have to “turn on” this feature (?).