# Finding example for GTK3

**URL:** <https://www.ruby-forum.com/t/finding-example-for-gtk3/231508>\
**Category:** Ruby\
**Created:** [August 12, 2014, 8:36pm UTC](https://www.ruby-forum.com/t/finding-example-for-gtk3/231508 "2014-08-12T20:36:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![addis\_a](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c4cdca/32.png) [@addis\_a](https://www.ruby-forum.com/u/addis_a)\
**Post date:** [August 12, 2014, 8:36pm UTC](https://www.ruby-forum.com/t/finding-example-for-gtk3/231508/1 "2014-08-12T20:36:38Z")

</div>

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:

```auto
#!/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()
```

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

---

<div class="post-metadata">

**Author:** ![greeneco](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/3bc359/32.png) [@greeneco](https://www.ruby-forum.com/u/greeneco)\
**Post date:** [August 12, 2014, 9:33pm UTC](https://www.ruby-forum.com/t/finding-example-for-gtk3/231508/2 "2014-08-12T21:33:21Z")

</div>

> 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/](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](http://rubygems.org) for finding them.

---

<div class="post-metadata">

**Author:** ![greeneco](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/3bc359/32.png) [@greeneco](https://www.ruby-forum.com/u/greeneco)\
**Post date:** [August 15, 2014, 8:45am UTC](https://www.ruby-forum.com/t/finding-example-for-gtk3/231508/3 "2014-08-15T08:45:05Z")

</div>

My cremefraiche-gem is written against the gtk3 libraries. You can get  
it either from [rubygems.org](http://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.
