Showing posts with label FXRuby. Show all posts
Showing posts with label FXRuby. Show all posts

18.1.09

GUI toolkit extravaganza wrap-up

Folks, I have decided to conclude the GUI toolkit extravaganza. There were two more toolkits to follow, monkeybars and qtruby. But alas, I am not going to check those out any time soon. I just don't feel very curious about these toolkits anymore and want to do some more exploring of Shoes. But I'll take those two toolkits along in the following overview.

The big question is off course, which one is the best? It all depends on what you need and what effort you are willing to invest (ooh how cliché!). When it comes to GUI toolkits for Ruby, there are three basic categories: system-dependant, system-independent and the category for those that won't fit elsewhere. Let's take a brief look at each category:

System-dependant: ruby-gnome2 and qtruby
These are toolkits specifically written to support a certain system, a specific window manager for example. These toolkits offer a big load of functions, sometimes not even restricted to graphics. For example, ruby-gnome2 has some audio functionality as well. The amount of available functionality and the fact that you need to understand the given window manager as well, makes these toolkits a bit complex and the learning curve steep. I would only consider to learn and use these if I really needed to use some system specific functionality that other toolkits don't provide. Otherwise I'd walk on and find something more simple which I could use in more situations.

If you need to do some qt stuff here's some info:
a book
korundrun
: bindings for KDE and qt api's
KDE techbase

System-independent: fxruby and wxruby
Usually these toolkits are a layer cake of wrappers and libraries. Both are supported by many systems and allow you to code an app that looks the same on different systems. There is not much difference between these two toolkits. Fx is older which is bad because it just looks a bit dated, but on the other hand there is a decent amount of documentation, including a book on fxruby. Wx is a bit younger and looks better. One other difference is that wx is truly native, so all widgets are in the same style your window manager is. Fx looks mostly the same on different platforms. Both toolkits provide all standard GUI functions.

If you are looking for a toolkit to make mainstream GUI's I'd go for one of these. Walk on if you want something different, something that's more suited for beginners or something more fun.
Link
The category for those that won't fit elsewhere: Monkeybars & Shoes
Monkeybars:
This toolkit is for rubyists who evolved from Javabut still want to code swing but this time using Ruby code. So if you learned Swing in a past life and don't want to learn a new GUI language again, I guess this is for you! Here's some background info:
project page
Linkscreencastic screencast

Shoes:
My personal choice and recommendation. If you don't have very specific wishes you should try shoes and see if it fits! Why? Because it's the easiest and most enjoyable. If you later find that you need something which Shoes can't do you can always choose to learn something else.
To learn Shoes you only need to take 10 steps, so stay tuned as we take 10 steps with Shoes in the following postings!

24.11.08

GUI toolkit extravaganza part II: FXRuby

The FXRuby toolkit is the subject of the GUI toolkit extravaganza, part deux. In this 7 part series, we will take a look at the various GUI toolkits in existence to find the ultimate GUI toolkit. One of the best known GUI toolkits is FXRuby, wich we will look at in this post.

FXRuby
FXRuby is a library that enables Ruby code to use the Fox toolkit. Fox is a graphics toolkit which was written in C++ and known for it's speed. FXRuby was created way back in 2001 and one of it's aims is to provide a cross-platform Ruby GUI toolkit. Let's take a closer look!

ease of installation
FXRuby has an interactive installer for Windows systems. Macintosh systems can use the Mac ports. The sources are available so you can compile from source in any case. I had a bit of trouble installing it on my Ubuntu Hardy Heron system. But eventually I got it working. Here's what you need to do:
apt-get install libfox-1.6-0 libfox-1.6-dev libfox-1.6-doc
gem install fxruby

documentation
FXRuby has been nicely documented. The project website provides the complete API reference and a users guide.

There is also a book written solely about FXRuby. The project's website hosts two mailinglists as well.

supported platforms
FXRuby 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 FXRuby.

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
require 'fox16'
include Fox
app = FXApp.new
MainWindow = FXMainWindow.new(app, "FXwindow" ,
:width => 200, :height => 100)
FXButton.new(MainWindow,"Button",nil,nil,0,BUTTON_NORMAL|LAYOUT_CENTER_Y|LAYOUT_CENTER_X)
app.create
MainWindow.show(PLACEMENT_SCREEN)
app.run

functionality
FXRuby provides a standard set of graphical functions. But one feature that makes it stand out on the feature front is the support for OpenGL, providing the posibility to render cool 3-D graphics from your Ruby code.

performance
The Fox toolkit is known for it's speed and limited use of system recourses. From what I have seen, the same goes for FXRuby, it is light and it is fast.

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.



Update: ok, this does not help a lot. Here's an impression of one of the sample programs that come with Fxruby:
As you can see, it looks a bit like some apps did in the windows98 days...

You can find the FXRuby toolkit at:


Stay tuned for the GUI toolkit extravaganza part III: WxRuby