This gem is meant to make GUI development in Ruby easy, and even fun.

You can specify “easy window layout” in ASCII text, example, if you have a layout like this:

———- A Title ————————— | [a button:button1] [button text:button2] | | “some text2:text1” |


It will create a window that has buttons and text “like that,” with reasonable spacing.

Here’s how: >> frame = SimpleGuiCreator::ParseTemplate.new # or optionally subclass this instead, and call super in your constructor >> frame.parse_setup_filename ‘some_filename’

You can then program behaviors like this:

>> frame.elements.on_clicked {

SimpleGuiCreator.show_blocking_message_dialog "you clicked button1!"

}

This separates your views from your controllers, in this case, because you can store the layouts in an entirely separate file, or embedded in the code. “Normal humans” can then edit the design layout files, for instance.

It also has helper methods for common GUI tasks, like the above show_blocking_message_dialog, and also: SimpleGuiCreator.new_nonexisting_filechooser_and_go # select file or filename for a “new file” (not yet existing) SimpleGuiCreator.new_existing_dir_chooser_and_go # select pre-existing directory SimpleGuiCreator.show_in_explorer(filename) # reveals file in Explorer for windows, Finder for OS X text_from_user = SimpleGuiCreator.get_user_input “Input your name:” # these raise an exception if the user cancels the dialog,

A select-button prompt dialog:

if(SimpleGuiCreator.show_select_buttons_prompt(“message title”, :yes => ‘text for the yes button’, :no => ‘text for the no button’, :cancel => ‘text for the cancel button’) == :yes)

# they chose the "yes" equivalent button...

end

etc. …

It provies a few helper methods to the ParseTemplate::JFramer (and JFrame) class, like:

#bring_to_front #minimize #restore #after_closed { … } #after_minimized { … }

It has helpers to control/playback audio, like mp3’s or wave’s, starting/stopping asynchronously (see the files in the ‘lib/ruby-easy-gui-creator’ directory. It has helpers to set/get system clipboard contents. It has helpers to control/query the mouse (I use this, but don’t know why anybody else ever would want to LOL). It has helpers to query the current system for its DVD drives, be notified when disks are inserted/changed, etc.

Feedback/feature requests welcome. groups.google.com/group/roger-projects, [email protected] I’d even be happy to wrap other gui frameworks (currently jruby/swing only) with the same helper functions, if anybody wanted it.

Enjoy!

To install/use:

$ gem install simple-ruby-gui-creator

>> require ‘simple_gui_creator’ >> … [see other examples]

GUI Editor ==

It also comes with its own “test as you go” design builder helper GUI, programmed, appropriately enough, using simple gui creator. $ jruby -S simple_gui_creator

This pulls up a window with some demo code, and some links that let you save it. It’s almost more of a “demo of how it works” than a real editing tool, but feature requests/suggestions wanted!

Documentation ==

Basically, see this file, the examples folder, the “bin/*” files, and also the specs and lib files themselves. github.com/rdp/ruby_simple_gui_creator

Known problems ==

Only allows single element types per line currently, like “all text” or “all buttons”, but I’m working on it :) Only Jruby today, which can make loading time painful (hint: use splash screen).