Forum: Ruby-Gnome 2 (debian,eclipse) add a button to a window created with glade

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
494fcef44bd4a43f5ec4068b3b0692ce?d=identicon&s=25 Olivier Saint-eve (lolveleys)
on 2009-04-25 16:12
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.
494fcef44bd4a43f5ec4068b3b0692ce?d=identicon&s=25 Olivier Saint-eve (lolveleys)
on 2009-04-25 16:14
and I add that with "irb" ie at the console, I succeed in creating a
button (a=Gtk::Button.new("hello").

olivier.
494fcef44bd4a43f5ec4068b3b0692ce?d=identicon&s=25 Olivier Saint-eve (lolveleys)
on 2009-04-25 16:26
it is now good, with this line:

a.main_glade_xml["hbox1"].pack_start(Gtk::Button.new("hello"), true,
true, 0)

olivier.
This topic is locked and can not be replied to.