Pages

Wednesday, August 17, 2011

Ruby GUI and FXRuby Installation

Why about GUI and FXRuby all of a sudden?

Its a tremendous movement we made from desktop to web 2.0 apps and again back to native desktop apps(iphone/ipad) Seesmic/Tweetdeck apps broadly classifying as RIA.

Hence my long time dream, has been pondering about throwing the silver cup of Java swing and bringing platinum Ruby stones in GUI front, finding space in replacing existing legacy Java swing applications with a neat Ruby GUI like TK-Ruby.

To my horror, nothing has been honored in Ruby world apart from Rails and geeks see Ruby as a Web DSL and where as rails has made routes.rb itself a DSL.

I forayed to figure out any Ruby GUI library in par with AIR/Silverlight, but my search collaboration with mountain view only ended up in disparity.

Finally ended up in installing FXRuby to see fortune in it, written a small GUI ruby program as below,


require 'rubygems'
require 'fox16'
include Fox


application = FXApp.new("CompositeGUI", "CompositeGUI")
main_window = FXMainWindow.new(application, "Composite",nil, nil, DECOR_ALL)
main_window.width = 400
main_window.height = 200


#Vertical Frame
super_frame = FXVerticalFrame.new(main_window,LAYOUT_FILL_X|LAYOUT_FILL_Y)
FXLabel.new(super_frame, "Text Editor Application")


#Horizontal Frame
text_editor = FXHorizontalFrame.new(super_frame,LAYOUT_FILL_X|LAYOUT_FILL_Y)
text = FXText.new(text_editor, nil, 0,TEXT_READONLY|TEXT_WORDWRAP|LAYOUT_FILL_X|LAYOUT_FILL_Y)
text.text = "This is some text."


# Button bar along the bottom
button_frame = FXVerticalFrame.new(text_editor,LAYOUT_SIDE_RIGHT|LAYOUT_FILL_Y)
FXButton.new(button_frame, "Cut")
FXButton.new(button_frame, "Copy")
FXButton.new(button_frame, "Paste")


#create FX application and run
application.create
main_window.show(PLACEMENT_SCREEN)
application.run 


and when I ran, landed with the below error message,

LoadError: no such file to load -- fox16.so from line no 2 require 'fox16'
I installed fxruby-1.6.20-x86-linux.gem and wondering any fox library kit need to be installed in my system and searched in my ubuntu for fox library dependency but left with no clue.
Then I uninstalled and downloaded fxruby-1.6.20.gem and installed. Native extensions were built, then I could ran my fxruby program with ease,



Though not appealing, enough qualified to place it beside AIR or Silverlight GUI, this could be the half brother of Java Swing.

For enterprise Java swing applications and migrating it ruby I saw this article, 
Don't know practically how far this works