# (debian,eclipse) add a button to a window created with glade

**URL:** <https://www.ruby-forum.com/t/debian-eclipse-add-a-button-to-a-window-created-with-glade/166459>\
**Category:** Ruby-Gnome 2\
**Created:** [April 25, 2009, 4:12pm UTC](https://www.ruby-forum.com/t/debian-eclipse-add-a-button-to-a-window-created-with-glade/166459 "2009-04-25T16:12:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rvork](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/f6c823/32.png) [@rvork](https://www.ruby-forum.com/u/rvork)\
**Post date:** [April 25, 2009, 4:12pm UTC](https://www.ruby-forum.com/t/debian-eclipse-add-a-button-to-a-window-created-with-glade/166459/1 "2009-04-25T16:12:37Z")

</div>

hello,

I would like to create a window with glade, import it in a ruby project,  
and add a buton to it but from eclipse.

here it is an example:

* * *

#!/usr/bin/env ruby

# 

require ‘libglade2’  
require ‘gtk2’  
class MonAppli  
attr\_accessor:main\_glade\_xml  
def initialize(file, root)  
@main\_glade\_xml = GladeXML.new(file, root) {|handler|  
method(handler)}  
#@main\_glade\_xml[‘fenetre\_2’].show\_all end  
def on\_button1\_clicked  
puts “clicked !”  
end  
end

Gtk.init  
a=MonAppli.new("/home/lolveley/eclipse/plan\_de\_travail/test\_1/fenetre\_2.glade",nil)

a.main\_glade\_xml[“window1”].add\_child(new Button(“bouton 1”))

# marche

a.main\_glade\_xml[“window1”].show\_all  
Gtk.main

* * *

but I can’t find the correct term to use for “button” : I tried  
Gtk::button but I have this error then : “undefined method `Button’ for  
Gtk:Module”.

can you help me?

olivier.

---

<div class="post-metadata">

**Author:** ![rvork](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/f6c823/32.png) [@rvork](https://www.ruby-forum.com/u/rvork)\
**Post date:** [April 25, 2009, 4:14pm UTC](https://www.ruby-forum.com/t/debian-eclipse-add-a-button-to-a-window-created-with-glade/166459/2 "2009-04-25T16:14:12Z")

</div>

and I add that with “irb” ie at the console, I succeed in creating a  
button (a=Gtk::Button.new(“hello”).

olivier.

---

<div class="post-metadata">

**Author:** ![rvork](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/f6c823/32.png) [@rvork](https://www.ruby-forum.com/u/rvork)\
**Post date:** [April 25, 2009, 4:26pm UTC](https://www.ruby-forum.com/t/debian-eclipse-add-a-button-to-a-window-created-with-glade/166459/3 "2009-04-25T16:26:15Z")

</div>

it is now good, with this line:

a.main\_glade\_xml[“hbox1”].pack\_start(Gtk::Button.new(“hello”), true,  
true, 0)

olivier.
