Jump to content

Ruby Programming/GUI Toolkit Modules

From Wikibooks, open books for an open world

Ruby GUI toolkits are typically 3rd party GUI platforms that are driven (wrapped) by a Ruby driver.

Ruby bindings are available for several widget toolkits, among them Tk, Gtk, Fox, Qt, and SWT.

QtRuby

[edit | edit source]
  • QtRuby gives you Ruby bindings to the Qt toolkit (the toolkit used in the KDE desktop system).

Advantages:

  • Has a book.
  • Has Qt designer for help designing.
  • Gem is available for the Windows installation

Disadvantages:

  • Only source code is available for other platforms (but ruby-qt binding and libraries are often packaged by Linux distributions).

FXRuby

[edit | edit source]

FXRuby is a Ruby binding for the Fox GUI toolkit written in C++. It is available for installation using RubyGems.

Advantages:

  • Has a gem.

Disadvantages:

  • Non-native look and feel. It looks like Windows XP even on a Mac or in Windows 7.
  • Binary gems are available for Windows, OS X, and Ubuntu Linux but for other platforms, installing the gem requires you to compile native code.
  • Even with binary gems it has non-Ruby dependencies that cannot be packaged with the code thus requiring end users to manually download, compile, and install dependencies.

Shoes

[edit | edit source]

Shoes was originally written by _why, and is now maintained by others. Its aim is to make ruby GUI development actually fun.

Advantages:

  • Simple.
  • Cool graphics, control at a lower level, simple interface, can be used to distribute redistributables easily, used to have examples available.

Disadvantages:

  • 4.0.0-pre has gems that do work. [No gem (current gem, 3.0.1, is a place holder that does nothing), still a bit rough around the edges since it attempts to support so many platforms.]
  • Lacks many of the more robust widgets common in other toolkits.

Advantages:

  • Bindings are built-in to some Ruby distros.
  • Since Tk 8.5 it has had native look-and-feel for Windows, *nix and Mac.
  • Has Ruby-DSL for interface declaration.

Disadvantages:

  • When you install Ruby from source code, you need to be sure you also have the Tk dependencies and make sure the compilation settings include Tk.

Example project: arcadia

GNOME ruby

[edit | edit source]

Advantages:

  • Native look.

Disadvantages:

  • Bad windows support
  • Doesn't support multi threaded testing well.

RubyCocoa

[edit | edit source]

Advantages:

  • Well integrated with MacRuby, good balance between power and ease of coding. Good support for testing.

Disadvantages:

  • OS X only

JRuby toolkits

[edit | edit source]
  • Note that you can use the Rawr tool to cross-platform package any JRuby application so that it includes all the code plus JRuby. The only real external dependency when using JRuby + Rawr is Java. Also working with JRuby might integrate well with editing using NetBeans editor.

Swing wrappers

[edit | edit source]

Advantages:

  • Swing is built in to the JRI.
  • You can also create the UI using a traditional java visual developer, like NetBeans, then use it in Ruby.

Disadvantages:

  • Some wrappers libraries are a little rough.

Simple GUI creator

[edit | edit source]

This simplifies common tasks like asking for user input, dropdown forms, etc, and even has its own "Text based" layout engine, see here

This is the eclipse widget library, a competitor to Swing, in the Java world, and can be transparently used from JRuby. RedCar is a project using it that is pretty complete. Glimmer is an open-source JRuby wrapper that facilitates using SWT widgets via a light-weight DSL. Also see: book

Advantages:

  • Mature (used by Eclipse and supported)
  • Native widgets for the most part (like wxWidgets), supporting cross-platform native look and feel.
  • Extensive Java documentation around the toolkit.

Disadvantages:

  • JARs must be bundled for cross platform deployment.

Further reading

[edit | edit source]
  • "With what tools can I make a complex and advanced GUI with Ruby?". Software Recommendations Stack Exchange. New York City: Stack Overflow.
华夏公益教科书