Add a GUI to your Ruby Script

Hi:

If you want to add a GUI to your Ruby script thy this:

I’d like to get feedback on the install, and I’d be glad to answer any
questions. Please let me know what you think.

Yours,
Eric C

That looks kick-ass.

Dave Heitzman

Thanks Dave:

I just added support for ActiveRecord, and updated the docs.

If you get a chance, I’d love to hear your input on the project. A
decent number of people are downloading the rubygem, but I don’t get
much feedback. I’m not sure why. I’d like to know peoples’ experience
with it.

Thanks,
Eric C

I downloaded it , and had to do a bit of hacking to get it running on
my winXP system

One issue was my video settings had been changed to 16bit, and this
caused a
Gtk error:
Gdk-WARNING **:gdk_win32_pixmap_new: depth = 16 not supported
Resetting my display to 32bit resolved this

when installing the gtk2 gem it failed to install psych, as I had not
installed DevKit
Your install instructions don’t indicate the need for devkit, but
looks like it maybe necessary
Even with devkit the install of psych failed. A quick google and I
found instructions
(http://jonforums.github.com/ruby/2012/02/24/hacking-a-gem.html)
on hacking the psych gem to create a custom version that would install
on windows. Not for the beginner
but interesting if you like getting your hands dirty.
I haven’t had a chance to do much other than confirm that vr starts.
Was a bit surprised when it failed to start in a selected directory,
the root of my dev sandbox,
as it found too many files/dirs. I guess it assumes the current dir
is the root of the project you are working on?

Hope to get a chance to play with it more,

cheers,
Chris

I tried the flipcoin example in the “Build a Ruby GUI in 10 minutes”
tutorial, but I get this error message on running it:

/home/wybo/visualruby_examples/flipcoin$ ruby main.rb
/usr/local/lib/ruby/gems/1.9.1/gems/vrlib-0.0.31/lib/GladeGUI.rb: line
127
GLib-GObject-WARNING **:cannot create instance of abstract
(non-instantiatable) type `GtkBox’
Segmentation fault

After some googling, it looks like I would have to go back to glade 3.8
(from 3.10.0) and I tried, but this seems not to be trivial - is it?

I removed the psych dependency. Unfortunately, this will cause an error
in some versions of ruby due to a bug in bundler. Users will just have
to install psych themselves when needed. I’m using ruby 1.9.3 without
psych, and it works fine.

I don’t plan on addressing the 16 bit graphics issue because few poeple
will run into that problem, but thanks for the report!!!

Eric

Yes, I think you need glade 3.8. The new glade for GTK uses GTK3 which
has a general GtkBox. GTK2 uses a vbox and a hbox. Visual Ruby uses
GTK2, so you need to use glade 3.8.

I really don’t like that they combined the vbox and hbox together. It
only makes problems for all of us.

The good side is that gtk2 will be more stable anyway.

Let me know how it goes.

Eric

On 2012-04-10 01:08, Eric C. wrote:

Yes, I think you need glade 3.8. The new glade for GTK uses GTK3 which
has a general GtkBox. GTK2 uses a vbox and a hbox. Visual Ruby uses
GTK2, so you need to use glade 3.8.

I really don’t like that they combined the vbox and hbox together. It
only makes problems for all of us.

The good side is that gtk2 will be more stable anyway.

Let me know how it goes.

OK, I removed my glade, unpacked glade3-3.8.0.tar.bz2,
ran ./configure && make && make install
That gave me only /usr/local/bin/glade-3, which says:

$ glade-3 --version
glade-3: error while loading shared libraries: libgladeui-1.so.11:
cannot open shared object file: No such file or directory

I also had src/.libs/{glade-3,lt-glace-3}
glade-3 was the same as /usr/local/bin/glade-3
lt-glade-3 said:

$ ./lt-glade-3 --version
glade3 3.8.0

linked it to /usr/local/bin/glade so that:
$ glade --version
glade3 3.8.0

but vr, with the flipcoin example, still said:

/home/wybo/visualruby_examples/flipcoin$ ruby main.rb
/usr/local/lib/ruby/gems/1.9.1/gems/vrlib-0.0.31/lib/GladeGUI.rb: line
127
GLib-GObject-WARNING **:cannot create instance of abstract
(non-instantiatable) type `GtkBox’
Segmentation fault

Hi:

I think there are two possibilities:

  1. Perhaps you edited the glade file for coinflip, and it now has a
    gtkbox in the xml. You could uninstall the gem and start over to make
    sure:

sudo gem uninstall coinflip.

Then install it again.

  1. You need to be using gtk2. The gtkbox is part of gtk3 (I think)
    Make sure you’re using gtk2.

Let me know if it works.

Also, you may want to just skip the coinflip program. There are several
example projects that ship with visualruby. Try those too. Let me know
how it goes.

Yours,
Eric

Eric

nice! gonna play with this tonight!

On 2012-04-10 22:58, Eric C. wrote:

Hi:

I think there are two possibilities:

  1. Perhaps you edited the glade file for coinflip, and it now has a
    gtkbox in the xml. You could uninstall the gem and start over to make
    sure:

sudo gem uninstall coinflip.

but coinflip is no a gem, it’s just a directory resulting from my trying
the “Build a Ruby GUI in 10 minutes”

Then install it again.

  1. You need to be using gtk2. The gtkbox is part of gtk3 (I think)
    Make sure you’re using gtk2.

I found out that there is, apart from glade, also a glade-gtk2 in my
xubuntu system. So I got to a fresh computer with a fresh xubuntu,
installed glade-gtk2 and visualruby.
I got to my ~/visualruby_examples and typed vr all_widgets and then
tried to edit the glade file, after changing the glade command line from
glade-3 into glade-gtk2 in Tools->Settings. But I got a window with the
nice tools, but an empty editing field. Plus these error messages in the
terminal:

visualruby_examples>vr all_widgets

(glade-gtk2:13030): GladeUI-WARNING **: Failed to open catalog directory
‘’: Error opening directory ‘’: No such file or directory

(glade-gtk2:13030): GladeUI-WARNING **: Failed to open catalog directory
‘’: Error opening directory ‘’: No such file or directory
GladeUI-Message: No displayable values for property
GtkToolPalette::icon-size
GladeUI-Message: No displayable values for property
GtkToolItemGroup::ellipsize
GladeUI-Message: No displayable values for property
GtkToolItemGroup::header-relief

(glade-gtk2:13030): GladeUI-CRITICAL **: Unable to load module ‘vte’
from any search paths

(glade-gtk2:13030): GladeUI-WARNING **: Failed to load external library
‘vte’

(glade-gtk2:13030): GladeUI-WARNING **: We could not find the symbol
“vte_terminal_get_type”

(glade-gtk2:13030): GladeUI-WARNING **: Could not get the type from
“VteTerminal”

(glade-gtk2:13030): GladeUI-WARNING **: Failed to load the GType for
‘VteTerminal’

(glade-gtk2:13030): GladeUI-WARNING **: Tried to include undefined
widget class ‘VteTerminal’ in a widget group
GladeUI-Message: Glade needs artwork; a default icon will be used for
the following classes:
GtkSourceView needs an icon named
‘widget-gtksourceview-gtksourceview’
GladeUI-Message: The DevHelp installed on your system is too old,
devhelp feature will be disabled.