(debian,eclipse) GUI created with glade does not appear

hi,

some informations:

  • I have debian lenny, with gnome
  • I have eclipse + the plugin DLTK (for ruby)
  • I have installed the packages ruby1.8, ruby1.8-dev, ruby-gnome2,
    libglade-2, glade-gnome and glade-3.

I thought I have all installed but when I follow this tutorial : (in
french) :
http://www.rubyfr.org/documentations/ruby-ihm/ruby-gnome/gnome2-glade/ ,
I launch the project under eclipse (“run script”) and … nothing
happens : no error message, no message at the console.
if I add “puts ‘hello’” at the end of the script … it doesn’t appear
at the console window…

maybe there is a problem with libglade2 and gtk2, but what is it?

the gem tool tells me there is no gem installed (maybe libglade2 and
gtk2 aren’t recognized, but how to be sure?).

olivier.

Did you set the window ‘visible’ in glade? Or you can call ‘show’ or
‘show_all’ on the window.

There are also many existing ruby/glade applications that you could
examine, such as:
https://launchpad.net/screenruler

On Fri, Apr 24, 2009 at 1:24 PM, Olivier Saint-eve

hello,

thx for your answer.
I tried your program, and it works well.

can you tell me how to call the method show_all in the program
following:


#!/usr/bin/env ruby

This file is gererated by ruby-glade-create-template 1.1.4.

require ‘libglade2’
require ‘gtk2’

class Fenetre2Glade
include GetText

attr :glade

def initialize(path_or_data, root = nil, domain = nil, localedir =
nil, flag = GladeXML::FILE)
bindtextdomain(domain, localedir, nil, “UTF-8”)
@glade = GladeXML.new(path_or_data, root, domain, localedir, flag)
{|handler| method(handler)}

end

def on_button1_clicked(widget)
puts “on_button1_clicked() is not implemented yet.”
end
end

Main program

if FILE == $0

Set values as your own application.

Gtk.init
PROG_PATH = “fenetre_2.glade”
PROG_NAME = “YOUR_APPLICATION_NAME”
a=Fenetre2Glade.new(PROG_PATH, nil, PROG_NAME)
Gtk.main
puts “fini”
end


lolveley.

I tried to enter a.show_all() but I think it’s wrong.

olivier.

Hi,

am Sat, 25 Apr 2009 08:06:09 +0200, tat Olivier Saint-eve
[email protected] der Welt kund:

def initialize(path_or_data, root = nil, domain = nil, localedir =
nil, flag = GladeXML::FILE)
bindtextdomain(domain, localedir, nil, “UTF-8”)
@glade = GladeXML.new(path_or_data, root, domain, localedir, flag)
{|handler| method(handler)}

@glade[‘name_of_your_window’].show_all

Gtk.init
PROG_PATH = “fenetre_2.glade”
PROG_NAME = “YOUR_APPLICATION_NAME”
a=Fenetre2Glade.new(PROG_PATH, nil, PROG_NAME)
Gtk.main
puts “fini”
end


lolveley.

Cheers, detlef


http://det.cable.nu

hello,

I tried this program:


#!/usr/bin/env ruby

require ‘libglade2’
require ‘gtk2’
class MonAppli
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)

Gtk.main

puts “hello”


but I obtain two errors:

  • first, the line with “show_all” is rejected : the compiler says that
    the nil object doesn’t have the method “show_all” (the error seems hence
    to be at the line above, the GladeXML.new)
  • secondly : after “a=MonAppli.new…”, I tried “a.glade” but it is not
    recognized.in theory, is it well? why can’t I obtain this field?

olivier.

I succeeded in displying the window!
I changed the path to the file fenetre_2.glade, with the path of the
copy of the file but in an other directory, and it went well.

nevertheless, do you know the answer at the two questions in my previous
post?

it still doesn’t run.

olivier.

I add that the initial “.glade” file was corrupted, so when I made
another “.glade” file all worked good.

olivier.

am Sat, 25 Apr 2009 12:39:30 +0200, tat Olivier Saint-eve
[email protected] der Welt kund:

Hi,

but I obtain two errors:

  • first, the line with “show_all” is rejected : the compiler says that
    the nil object doesn’t have the method “show_all” (the error seems hence
    to be at the line above, the GladeXML.new)

I tried your example and it works for me.

If Glade doesn’t find the glade file you will get a error message like

libglade-WARNING **:could not find glade file

But you get an error message, that show_all doesn’t exist for nil. That
means that your glade file is successfully loaded. But in you glade
file is no object called fenetre_2.

With @main_glade_xml[‘some_widget’] you ask for a widget, that is
called some_widget in your glade file. So your main window has to be
named fenetre_2.

Btw. it would be useful, if you also post the error output of the
console for the example code.

Cheers, detlef


http://det.cable.nu

It might look something like this:

main_window = a.get_widget(‘main_window’)
main_window.show # see also: main_window.present

best,
-Ian

On Fri, Apr 24, 2009 at 11:06 PM, Olivier Saint-eve

thanks detlef, there is no need to post another message, all works fine!

olivier.

Oops, too late. Glad you got it working.

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