I generally try to stay away from writing GUI applications and focus on server side development instead. Still, every once in a while I have an idea for a GUI tool that I’d like to build. My previous post on the upcoming Rapid GUI Development with QtRuby book prompted me to (once again) look into the available GUI toolkits for Ruby.
Unlike Java, which has pretty much standardized on the Swing and SWT frameworks, Ruby does not have any clear winners yet. Out of the box, it ships with Tk, which is horribly antiquated and not very Ruby-like. Luckily, a whole bunch of additional frameworks have been built. Most of these are Ruby wrappers around existing GUI toolkits.
Here are some discussions on Ruby GUI toolkits:
After scanning through the discussions above, the following GUI toolkits seem to be particularly worth a closer look:
This is a Ruby binding for the platform independent C++ FOX toolkit. Among other things, this is used for the FreeRIDE Ruby IDE. It does not use native widgets, but based on the samples in the online manual it has a pretty nice look & feel, as well as many useful widgets. It also appears to be under active development and seems to be gaining a lot of traction.
Similar to FXRuby, xwRuby is a binding for the C++ wxWidgets library. The main difference between wxWidgets and FOX is that wxWidgets uses native widgets whenever possible, which should allow applications built with it to better fit into the host environment. Unfortunately it seems like the existing wxRuby binding (which is almost a year old) is immature at this point. According to the website, development on wxRuby2, which will use SWIG to generate the wrappers, has begun. It’s probably worth keeping an eye on this, although it doesn’t sound quite ready for prime time at this point.
This is a set of Ruby bindings for the (C++) Qt and KDE frameworks respectively. It is also the framework that is covered by the Pragmatic Friday title “Rapid GUI Development with QtRuby” that originally prompted me to write this post. I used Qt with C++ about 8 years ago, and found it a very nice toolkit to work with at the time (of course back then I still liked C++, so my judgement may have been clouded ;) ). I’m sure it’s evolved even further since then, and the fact that the KDE desktop environment is built on top of Qt is testament to the strength of this solution. This one definitely seems to be worth looking into. One potential issue may be Windows support. A Qt version for Windows exists, but I recall coming across some weird licensing policies for this - not sure if this is still the case, but it’s something to look into if you’re going to build anything other than an open source application.
Same as above, except for GTK2 / Gnome. As with QtRuby, this seems like a great choice for Linux, but I am less sure about Windows. Reportedly GTK2 still has some stability issues on Windows (although I am happily running Gaim on my WIndows laptop).
This is another very portable (all relevant desktop platforms as well as many embedded platforms are supported) GUI library that includes Ruby bindings (as well as bindings for many other languages). It includes a GUI builder application, which may be useful. It also integrates with OpenGL, although I believe the same is true for most of the other toolkits on this list.
This one’s definitely different… For many applications, I would consider simply building them as web applications (most likely using Rails) and running them locally using the WEBrick server, thus turning the browser into the GUI. RubyWebDialogs takes this idea a step further and provides an API that completely abstracts the web layer and allows you to develop as with any other GUI toolkit, even though it ultimately generates HTML pages that are rendered by your browser. It does not sound like the most straightforward way to build an application, but the examples look pretty simple, so this probably deserves a look. It appears to be reasonably lightweight and self contained and does not even use an external HTTP server such as WEBrick.