11.12.08

GUI toolkit extravaganza part III: WxRuby

In the previous part of the GUI toolkit extravaganza we looked at the FXRuby toolkit. This time we will spend some time to look at the Yin of FXRuby's Yang, the wxRuby toolkit.

wxRuby
wxRuby is a library that enables Ruby code to use the wxWidgets library. wxWidgets is a cross-platform GUI library written in C++. wxRuby has arrived at version 2 so we will look at that one. Not only the name sounds like FXRuby but also it's features seem alike. Let's find out if there are any differences!

ease of installation
xwruby2 is available as a Ruby gem. This makes the installation process very easy. According to the documentation, all you have to do is: sudo gem install wxruby2. There are also binary and source packages are available. On my Ubuntu Hardy Heron system, this did not do the trick however. Apperently there is something else you need to to apart from installing the gem, and this is poorly documented. You can read more about the problems installing wxruby2 in my previous post.

documentation
There seems to be quite a decent ammount of documentation for wxruby2. The project website provides the complete API reference and a Tutorial. As far as I'm aware there are no books about wxruby2, nor have I seen it featured in a book. The project's website hosts two mailinglists.

supported platforms
Wxruby has been created to provide a cross platform GUI toolkit, so it runs on multiple platforms. Systems running Linux, UNIX, Windows or Os/X are all supported by wxruby.

complexity
Take a look at the following code sample. We create a main window and place a button on it. We use PLACEMENT_SCREEN to center it. Piece of cake!

#!/usr/bin/env ruby
#!/usr/bin/env ruby
require 'wx'
Wx::App.run do
frame = Wx::Frame.new(nil, :title => "wxRuby window")
button = Wx::Button.new(frame, :label => 'Button')
evt_button(button) { puts 'WXRuby' }
frame.show
end

functionality
wxruby2 provides a standard set of graphical functions. The focus lies on cross-platform availability and the usage of native window designs. So on a GNOME system, you get GTK look and feel, on and on Mac OS/X you get aqua and on Windows you get the well known theme from Redmond. I am curious though as how much of windows, aqua and gtk functionality is supported...Unfortunately, finding that out would take more time then I have at the moment.

performance
There was some flickering going on at the top of the window sometimes. But I have noticed that on Fxruby windows as well since I upgraded my system to Ubuntu Intrepid. It does not seem like it's a problem caused by any of these two kits. Otherwise this performs just good.

looks
There's not much difference to be seen in the example provided here and the one previously provided in parts I of the GUI toolkit extravaganza. There are some minimal details around the buttons and edges. Reason is that it uses native graphics, so on my system it uses GTK in the end. Instead of adding yet another picture of a window with one button with only miniscule differences. Here's a picture from one of the sample programs, in this case,



You can find the wxruby2 toolkit at:
http://wxruby.rubyforge.org

Next up for the GUI toolkit extravaganza part IV is Shoes!

No comments: