Forum: Ruby Finding example for GTK3

427305650de0950b70adeb74be2274b8?d=identicon&s=25 Green Eco (greeneco)
on 2014-08-12 20:36
Hi,

I want to make a little nice GUI for an Arduino project I am currently
working on, I want to use Ruby for it. I do not want to use
"ruby-gnome2". So I have not put this into the "Ruby-Gnome2" section So
I use Glade to "produce" my GUI and then I want to write my Ruby code.
After some research I have found out how to make it work at a minimum:

[code]
#!/usr/bin/env ruby
require 'rubygems'
require 'gtk3'


def testfunction()
  print "Hello"
end


builder = Gtk::Builder.new
builder.add_from_file("test.glade")
builder.connect_signals {|handler| method(handler) }

window = builder.get_object("window1")
window.show_all()

Gtk.main()
[/code]

It is just a window with one button to press.
Ok I have not add a function that it closes correctly and such, but I
haven't use Ruby for some time and I am completly new when it comes to
GUIs. So I am currently looking for some examples or projects where I
can see how all this works and how more experience people do it and how
good programming style looks like. It would be very nice if you could
share some links or experiences or some code with me. :-)

I am looking forward to hear from you.

King regards,

Greeneco
B078cb4f4fb473c7a54d1fc36d10c70e?d=identicon&s=25 Regis d'Aubarede (raubarede)
on 2014-08-12 21:33
> working on, I want to use Ruby for it. I do not want to use
> "ruby-gnome2".

> require 'gtk3'

gtk3 is in ruby-gnome2 project !


>
>
> So I am currently looking for some examples or projects where I
> can see how all this works and how more experience people do it and how

for using glade and ruby, see visalruby :
http://visualruby.net/



if gui is simple, for one-script application, you can use :
* green-shoes : gtk2 + shoes DSL
* Ruiby : gtk3 DSL

both are gtk/ruby and lot of examples.

See rubygems.org for finding them.
1ea245dc79ad44fcaa9cbf821a354369?d=identicon&s=25 Michael Uplawski (frog_boche)
on 2014-08-15 08:45
My cremefraiche-gem is written against the gtk3 libraries. You can get
it either from rubygems.org (gem install) or Sourceforge. The latter
choice will provide you with zip- or 7z- files which also include the
gem.


All GUI-stuff is in a sub-directory of lib, so you should find your
examples. Know however that I added the GUI to an original command-line
project and do not give a damn about optimization or efficiency of my
using Gtk.
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.