Creating GUI applications with Ruby 1.9.1

I’m wanting to port over a GUI app I created into ruby so that it
maintains cross platform functionality.

Before I go into app specifications, I’m trying to gain an understanding
of what item(s) I will need to work with GUI applications in Ruby, and
more importantly, if there are any tutorials out there that can walk me
through creating a simple GUI app in Ruby.

I’m currently using Ruby 1.9.1, Ruby 1.8.7 EE, and Ruby 1.8.6 and can
develop on windows or linux. I have no idea what gem libraries I will
require. I’m willing to learn from any application before working on
the porting of my own code.

Any help would be appreciated.

Thanks.

I’m wanting to port over a GUI app I created into ruby so that it
maintains cross platform functionality.

Before I go into app specifications, I’m trying to gain an understanding
of what item(s) I will need to work with GUI applications in Ruby, and
more importantly, if there are any tutorials out there that can walk me
through creating a simple GUI app in Ruby.

This link might be helpful:

http://wiki.github.com/rdp/ruby_talk_faq/ruby-gui-toolkit-comparison

On 19.01.2010 05:17, Alpha B. wrote:

I’m wanting to port over a GUI app I created into ruby so that it
maintains cross platform functionality.

Before I go into app specifications, I’m trying to gain an understanding
of what item(s) I will need to work with GUI applications in Ruby, and
more importantly, if there are any tutorials out there that can walk me
through creating a simple GUI app in Ruby.

Well, usually just one item: the gem for the GUI library you pick to
chose. :slight_smile:

I’m currently using Ruby 1.9.1, Ruby 1.8.7 EE, and Ruby 1.8.6 and can
develop on windows or linux. I have no idea what gem libraries I will
require. I’m willing to learn from any application before working on
the porting of my own code.

Well, I know that wxRuby[0] is 1.9.1-safe. I’m not sure about the state
of things with Ruby-GNOME2[1], or Qt for Ruby[2].

From experience (with 1.8.6), I can say that Ruby-GNOME2 is quite easy
to work with, but requires a lot of dependencies (bundled with the
Windows installer, and resolved via package manager on Linux).

Both have good documentation, and useful tutorials, though wxRuby is in
the state of re-writing its documentation to reflect the changes of the
recent-ish 2.0 release, but the API documentation doesn’t leave anything
to be desired thus far (note: under Windows install wxRuby with “–no-ri
–no-rdoc” options, as it’ll slurp up all of your memory), and the state
for Ruby-GNOME2 is about the same.

I can’t say anything about the Qt bindings, however, but I expect the
docs being up to the same level (all three projects are about the same
age).

Then there’s of course JRuby which allows access to SWING (made easier
with Monkeybars), and IronRuby which allows access to WinForms, but I
don’t know if Mono supports IronRuby / enough of WinForms for your
needs.

Lastly, there’s Ruby’s Tk bindings, but… well, Tk is lacking in
documentation and in eyecandy, but it should already be installed.

Links:
[0] http://wxruby.rubyforge.org/
[1] http://ruby-gnome2.sourceforge.jp/
[2] http://techbase.kde.org/Development/Languages/Ruby

Thanks guys. I’ll look through all of the documentation and links
tomorrow morning.

Take care.

On Tuesday 19 January 2010, Phillip G. wrote:

|Well, I know that wxRuby[0] is 1.9.1-safe. I’m not sure about the state
|of things with Ruby-GNOME2[1], or Qt for Ruby[2].

Qt ruby works quite well with ruby 1.9 (at least, using recent
versions).

Stefano

Stefano C. wrote:

On Tuesday 19 January 2010, Phillip G. wrote:

|Well, I know that wxRuby[0] is 1.9.1-safe. I’m not sure about the state
|of things with Ruby-GNOME2[1], or Qt for Ruby[2].

Qt ruby works quite well with ruby 1.9 (at least, using recent
versions).

If you’re willing to use JRuby, I highly recommend Monkeybars.

Stefano

Best,
–Â
Marnen Laibow-Koser
http://www.marnen.org
[email protected]

“Qt could be better, but seems not easily available on macosx
(with macport for sample)”

Qt is available on every platform (I’m probably exagerating).
But surely it does on OSX, look simply their website. (The current
version
failed the installation at me on 10.6.2, I needed the 4.6.0)

2010/1/19 mdiam [email protected]

On Jan 19, 7:57 am, Stefano C. [email protected] wrote:

On Tuesday 19 January 2010, Phillip G. wrote:

|Well, I know that wxRuby[0] is 1.9.1-safe. I’m not sure about the state
|of things with Ruby-GNOME2[1], or Qt for Ruby[2].

Qt ruby works quite well with ruby 1.9 (at least, using recent versions).

A standard GUI should be easy to install on every platform.
Tk is easy to install,
Java is available every where too
Qt could be better, but seems not easily available on macosx
(with macport for sample)

Maurice

Phillip G. wrote:

chose. :slight_smile:

I’m currently using Ruby 1.9.1, Ruby 1.8.7 EE, and Ruby 1.8.6 and can
develop on windows or linux. I have no idea what gem libraries I will
require. I’m willing to learn from any application before working on
the porting of my own code.

> Lastly, there's Ruby's Tk bindings, but.. well, Tk is lacking in > documentation and in eyecandy, but it should already be installed. >

There are actually pretty good docs here (you can hide the other
languages):
http://www.tkdocs.com/tutorial/index.html

-Justin

Today I’m going to be experimenting with the following:

TK, QT, Monkeybars, and another that I found that wasn’t mentioned:

Titanium : http://www.appcelerator.com/

Thanks everyone. Wish me luck and I’ll post back with my findings.

Bah, I forgot to include links:

Getting Started with Titanium:
http://www.codestrong.com/titanium/guides/get_started/chapter_1/
Titanium API:
http://www.codestrong.com/titanium/api/
Ruby Documentation:
http://www.codestrong.com/titanium/guides/ruby/

enjoy.

Okay, doing a quick response here to my first experimentation with
Titanium. It’s actually an interesting development tool and has
promise.

I’m currently using Titanium Developer 0.8.2 on windows. The app has
some interesting pieces to it. It contains the following:

Packaging: Allows you to package for all OS types and also determine
whether it’s a network or bundled installation. The development tool
does all of the packaging for you with “one click” of a button. So,
packaging is a big plus in Titanium.

Programming: It does allow you to program code in Ruby, Python, and
PHP. With Ruby it includes the 1.8 libraries so it doesn’t allow 1.9.
While that’s a minus, I’m more familiar with 1.8 coding than 1.9 so it’s
not a big thing for me. When you include Ruby into your program, you
can create any ruby code in 1.8 on your own and include it into your
app. You can also include all JS scripting libraries (they have all of
them available). This is a big plus.

Setup: Pretty simple to setup. Your project directory contains an xml
file called tiapp.xml which allows you to choose how the window layouts
can be altered, stretched, starting width, height, etc. and also where
the root app begins. The starting app is an index.html file believe it
or not. You can change this to (NameOfYourProgram.html) and then point
the tiapp.xml file to the right location.

Folder Structure: It’s dynamic from what I see. You have a resources
folder where everything is lumped and dropped into this container.
However, you can change the entire structure to your own needs. You can
create folders for example as ruby, scripts, images, icons and place
your ruby files that you make in ruby, your js files in scripts, and all
your images in images, and icons in icons for instance. Then in your
app (index.html) you specify references using app://icons/myIcon.gif and
it automatically knows where to find the resource. Pretty flexible so
far on manipulating how you like to setup your projects.

Development: This is where it’s gotten interesting. I’m going to
supply a quick and dirty hello world app I created using gist.

http://gist.github.com/281023

As you can see, in the document, you can specify ruby code inside of
script tags and just run ruby code right there. Titanium knows that
it’s ruby and compiles it as such. You don’t have to place ruby code in
there. You can specify the location of one or more ruby files and place
them all throughout your app. When you package and test it (takes
approx. 15 seconds total to complete) you can push a button and it says
Hello World inside of your app container. Because it’s html you can
design your app flexibly with CSS. Pretty amazing stuff so far. I also
enclosed the tiapp.xml file showing you how it lays out your app.

Sandbox: There’s a sandbox tab inside the development where you can
throw any code structure and run it and it compiles and tests the code
to see if it works properly. I think this is one of the better features
because inside the sandbox you can include exactly what type of scripts
you want to use, if you want to add them.

So far, this is a pretty interesting development tool and I’m going to
play around with it for the rest of the day.

Alpha B. schrieb:

It rather seems you have to write the
documentation yourself:
http://www.codestrong.com/titanium/guides/get_started/chapter_5/#B
http://www.codestrong.com/titanium/guides/get_started/chapter_7/#A

–webkit btw.
-roger

A standard GUI should be easy to install on every platform.
Tk is easy to install
Java is available every where too

I’d imagine that multi-platform is easier with jruby (rawr) or
appcelerator or possibly tk or qt.

If you want to use tk on your windows distro [and are using mingw 1.9.x]
you can install it as a gem from

http://github.com/rdp/tk_as_gem

Also thanks for the links and review of appcelerator–I’ve added it to
the list

http://wiki.github.com/rdp/ruby_talk_faq/ruby-gui-toolkit-comparison

    --without-tcl85lib

extconf.rb:154:in require': no such file to load -- display (LoadError) from extconf.rb:154:infind_tcl’

oops left a line of debug code in there.
or install the ‘display’ gem :slight_smile:

you also “might” need Tcl 8.4–give 'era shot, though, with 8.5…

-rp

Roger P. wrote:

you also “might” need Tcl 8.4–give 'era shot, though, with 8.5…

gem install tk_as_gem --platform x86-mingw32
Building native extensions. This could take a while…
Successfully installed tk_as_gem-0.0.1
1 gem installed
Installing ri documentation for tk_as_gem-0.0.1…
Updating class cache with 1669 classes…
Installing RDoc documentation for tk_as_gem-0.0.1…

C:\Users\Joel>irb
irb(main):001:0> require “tk”
=> true

Works fine Roger - many thanks. I’m going to bypass Titanium and play
with TK instead because Titanium is missing a lot of documentation.

Alpha B. wrote:

Roger P. wrote:

you also “might” need Tcl 8.4–give 'era shot, though, with 8.5…

gem install tk_as_gem --platform x86-mingw32
Building native extensions. This could take a while…
Successfully installed tk_as_gem-0.0.1
1 gem installed
Installing ri documentation for tk_as_gem-0.0.1…
Updating class cache with 1669 classes…
Installing RDoc documentation for tk_as_gem-0.0.1…

C:\Users\Joel>irb
irb(main):001:0> require “tk”
=> true

Works fine Roger - many thanks. I’m going to bypass Titanium and play
with TK instead because Titanium is missing a lot of documentation.

But apparently, Ruby/Tk has an awful API. The Ruby GUI survey at
pressure.to found that developers rated Ruby/Tk dead last in quality of
API, and recommended that it be removed from the standard library. You
probably want to use something else.

Best,
–Â
Marnen Laibow-Koser
http://www.marnen.org
[email protected]

On Jan 19, 9:06 pm, Marnen Laibow-Koser [email protected] wrote:

Installing RDoc documentation for tk_as_gem-0.0.1…
API, and recommended that it be removed from the standard library. You
probably want to use something else.

I could not agree more. After trying to make an application with Ruby/
Tk I’ve switched to WxRuby which works equally well under the Linux
and Windows and Ruby 1.8.6 and 1.9.1.

Regards,
Bosko I.

Roger P. wrote:

A standard GUI should be easy to install on every platform.
Tk is easy to install
Java is available every where too

I’d imagine that multi-platform is easier with jruby (rawr) or
appcelerator or possibly tk or qt.

If you want to use tk on your windows distro [and are using mingw 1.9.x]
you can install it as a gem from

http://github.com/rdp/tk_as_gem

Also thanks for the links and review of appcelerator–I’ve added it to
the list

http://wiki.github.com/rdp/ruby_talk_faq/ruby-gui-toolkit-comparison

I tried to install this as a gem using many types of combinations:

gem install tk_as_gem --platform x86-mingw32
gem install tk_as_gem --source http://github.com/rdp/tk_as_gem
–platform x86-mingw32
etc.

The second one fails saying it can’t find a gem. The first one fails,
even thought I have activetcl installed in C:\tcl and it’s included in
my path and verified.

ERRORS:

C:\Users\Joel>gem install -d tk_as_gem --platform x86-mingw32
Building native extensions. This could take a while…
ERROR: Error installing tk_as_gem:
ERROR: Failed to build gem native extension.

C:/Ruby19/bin/ruby.exe extconf.rb
checking for ruby_native_thread_p() in ruby.h… yes
checking for rb_errinfo() in ruby.h… yes
checking for rb_safe_level() in ruby.h… yes
checking for struct RArray.ptr in ruby.h… no
checking for struct RArray.len in ruby.h… no
checking for tcl.h… no
checking for tcl.h in
/usr/local/include,/usr/pkg/include,/usr/include,/Tcl/incl
ude,/usr/local/include/tcl8.4,/usr/pkg/include/tcl8.4,/usr/include/tcl8.4,/Tcl/i
nclude/tcl8.4,/usr/local/include/tcl8.7,/usr/pkg/include/tcl8.7,/usr/include/tcl
8.7,/Tcl/include/tcl8.7,/usr/local/include/tcl8.6,/usr/pkg/include/tcl8.6,/usr/i
nclude/tcl8.6,/Tcl/include/tcl8.6,/usr/local/include/tcl8.5,/usr/pkg/include/tcl
8.5,/usr/include/tcl8.5,/Tcl/include/tcl8.5,/usr/local/include/tcl8.3,/usr/pkg/i
nclude/tcl8.3,/usr/include/tcl8.3,/Tcl/include/tcl8.3,/usr/local/include/tcl8.2,
/usr/pkg/include/tcl8.2,/usr/include/tcl8.2,/Tcl/include/tcl8.2,/usr/local/inclu
de/tcl8.1,/usr/pkg/include/tcl8.1,/usr/include/tcl8.1,/Tcl/include/tcl8.1,/usr/l
ocal/include/tcl8.0,/usr/pkg/include/tcl8.0,/usr/include/tcl8.0,/Tcl/include/tcl
8.0,/usr/local/include/tcl7.6,/usr/pkg/include/tcl7.6,/usr/include/tcl7.6,/Tcl/i
nclude/tcl7.6… yes
checking for tk.h… yes
checking for Tcl_FindExecutable() in -ltcl8.4… no
checking for Tcl_FindExecutable() in -ltcl84… no
checking for Tcl_FindExecutable() in -ltcl8.4g… no
checking for Tcl_FindExecutable() in -ltcl84g… no
checking for Tcl_FindExecutable() in -ltcl8.4… no
checking for Tcl_FindExecutable() in -ltcl84… no
checking for Tcl_FindExecutable() in -ltcl8.4g… no
checking for Tcl_FindExecutable() in -ltcl84g… no
checking for Tcl_FindExecutable() in -ltcl8.7… no
checking for Tcl_FindExecutable() in -ltcl87… no
checking for Tcl_FindExecutable() in -ltcl8.7g… no
checking for Tcl_FindExecutable() in -ltcl87g… no
checking for Tcl_FindExecutable() in -ltcl8.7… no
checking for Tcl_FindExecutable() in -ltcl87… no
checking for Tcl_FindExecutable() in -ltcl8.7g… no
checking for Tcl_FindExecutable() in -ltcl87g… no
checking for Tcl_FindExecutable() in -ltcl8.6… no
checking for Tcl_FindExecutable() in -ltcl86… no
checking for Tcl_FindExecutable() in -ltcl8.6g… no
checking for Tcl_FindExecutable() in -ltcl86g… no
checking for Tcl_FindExecutable() in -ltcl8.6… no
checking for Tcl_FindExecutable() in -ltcl86… no
checking for Tcl_FindExecutable() in -ltcl8.6g… no
checking for Tcl_FindExecutable() in -ltcl86g… no
checking for Tcl_FindExecutable() in -ltcl8.5… no
checking for Tcl_FindExecutable() in -ltcl85… yes
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.

Provided configuration options:
–with-opt-dir
–without-opt-dir
–with-opt-include
–without-opt-include=${opt-dir}/include
–with-opt-lib
–without-opt-lib=${opt-dir}/lib
–with-make-prog
–without-make-prog
–srcdir=.
–curdir
–ruby=C:/Ruby19/bin/ruby
–with-tcl-framework-header
–without-tcl-framework-header
–with-tk-framework-header
–without-tk-framework-header
–with-tcltk-framework
–without-tcltk-framework
–enable-tcltk-framework
–disable-tcltk-framework
–enable-mac-tcltk-framework
–disable-mac-tcltk-framework
–with-tk-dir
–without-tk-dir
–with-tk-include
–without-tk-include=${tk-dir}/include
–with-tk-lib
–without-tk-lib=${tk-dir}/lib
–with-tcl-dir
–without-tcl-dir
–with-tcl-include
–without-tcl-include=${tcl-dir}/include
–with-tcl-lib
–without-tcl-lib=${tcl-dir}/lib
–with-X11-dir
–without-X11-dir
–with-X11-include
–without-X11-include=${X11-dir}/include
–with-X11-lib
–without-X11-lib=${X11-dir}/lib
–with-tk-lib
–without-tk-lib
–with-tcl-lib
–without-tcl-lib
–with-X11-lib
–without-X11-lib
–with-tklib
–without-tklib
–with-tcllib
–without-tcllib
–enable-tcltk_stubs
–disable-tcltk_stubs
–with-tcltk_stubs
–without-tcltk_stubs
–with-tcltkversion
–without-tcltkversion
–with-X11
–without-X11
–with-tcl8.4lib
–without-tcl8.4lib
–with-tcl84lib
–without-tcl84lib
–with-tcl8.4glib
–without-tcl8.4glib
–with-tcl84glib
–without-tcl84glib
–with-tcl8.4lib
–without-tcl8.4lib
–with-tcl84lib
–without-tcl84lib
–with-tcl8.4glib
–without-tcl8.4glib
–with-tcl84glib
–without-tcl84glib
–with-tcl8.7lib
–without-tcl8.7lib
–with-tcl87lib
–without-tcl87lib
–with-tcl8.7glib
–without-tcl8.7glib
–with-tcl87glib
–without-tcl87glib
–with-tcl8.7lib
–without-tcl8.7lib
–with-tcl87lib
–without-tcl87lib
–with-tcl8.7glib
–without-tcl8.7glib
–with-tcl87glib
–without-tcl87glib
–with-tcl8.6lib
–without-tcl8.6lib
–with-tcl86lib
–without-tcl86lib
–with-tcl8.6glib
–without-tcl8.6glib
–with-tcl86glib
–without-tcl86glib
–with-tcl8.6lib
–without-tcl8.6lib
–with-tcl86lib
–without-tcl86lib
–with-tcl8.6glib
–without-tcl8.6glib
–with-tcl86glib
–without-tcl86glib
–with-tcl8.5lib
–without-tcl8.5lib
–with-tcl85lib
–without-tcl85lib
extconf.rb:154:in require': no such file to load -- display (LoadError) from extconf.rb:154:infind_tcl’
from extconf.rb:407:in `’

But apparently, Ruby/Tk has an awful API. The Ruby GUI survey at
pressure.to found that developers rated Ruby/Tk dead last in quality of
API, and recommended that it be removed from the standard library. You
probably want to use something else.

Best,

Thanks Marnen,

The nice thing about having so many knowledgeable people here is that I
get to browse and play with a lot of different GUI platforms. I’ve
already started to play with TK and compared to some areas of
development, I’m not having much trouble understanding the API.

The first thing I’m doing is translating their TKDocs so that it only
shows TK and Ruby and I’ve removed perl/python from their documentation.
I’ve also cleaned up the experience and formatted the document into pdf
which I emailed to my kindle for off-hours reading.

There’s also a full application at github for Arcadia which uses TK and
I downloaded it and am browsing some of the files.

The one thing that helps me with all of this is I used to create many
GUI applications with numerous languages, namely C++, C#, VB, AutoIt,
and Java. I already have my code formatted and ready to port. All I
needed was something to port it over to. I wrote GoogleHack in AutoIt
which is not an object oriented language. But, I wrote it using
functions that were used very similar to classes. So, as I’m porting
over the code to ruby, it’s not all that difficult. As for the elements
in TK, not finding it that difficult either.

What can I say… I’m a sponge.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs