You are not logged in.

#1 2006-04-08 18:40:23

rasat
Forum Fellow
From: Finland, working in Romania
Registered: 2002-12-27
Posts: 2,293
Website

Ruby+Glade - howto get an image in GtkImage widget?

What's the simplest way to get an image to appear in Glade's GtkImage widget?
This what I tried, but "add" or "insert" doesn't" work.

## Shows the GtkImage widget.
@image_box = @glade["image_pkg"].show 

## Loads an image.
def on_image_pkg_event(widget, arg0)
    image = Gtk::Image.new("test.jpg")
    @image_box.add(image)
end

Markku

Offline

#2 2006-04-09 00:20:29

iphitus
Forum Fellow
From: Melbourne, Australia
Registered: 2004-10-09
Posts: 4,927

Re: Ruby+Glade - howto get an image in GtkImage widget?

what sorta widget is image_pkg / image_box ? It should only need to be an empty event box for the above to work.

James

Offline

#3 2006-04-09 05:02:01

rasat
Forum Fellow
From: Finland, working in Romania
Registered: 2002-12-27
Posts: 2,293
Website

Re: Ruby+Glade - howto get an image in GtkImage widget?

The name of the GtkImage widget I named as "image_pkg" and "image_box" is an arry. I simply copied a sample how a text view widget was coded.


Markku

Offline

#4 2006-04-09 07:33:03

iphitus
Forum Fellow
From: Melbourne, Australia
Registered: 2004-10-09
Posts: 4,927

Re: Ruby+Glade - howto get an image in GtkImage widget?

rasat wrote:

The name of the GtkImage widget I named as "image_pkg" and "image_box" is an arry. I simply copied a sample how a text view widget was coded.

The problem here, is the .new function, creates an entirely new image object.

Image_pkg is not a container object, it's an image object, and you cannot .add another object to an image.

So you're choices are, here, to change image_pkg in the glade, to a container based object such as a event_box or alignment.

or.

change gtk::image.new to code that creates a gdk::image, and uses image_box.set_image to set the gtk::image's image to the newly created gdk::image.

James

(note, gdk not a misspelling)(im no expert, im trying to interpret this from my experience with glade+python+gtk2)

Offline

#5 2006-04-09 14:05:38

rasat
Forum Fellow
From: Finland, working in Romania
Registered: 2002-12-27
Posts: 2,293
Website

Re: Ruby+Glade - howto get an image in GtkImage widget?

I am still missing something. I changed the GtkImage to GtkEventbox widget using same name "image_pkg".
(correction: @image_box is a variable not arry)

@glade = GladeXML.new(path_or_data, root, domain, localedir, flag) {|handler| method(handler)}

@image_box = @glade["image_pkg"].show

image = Gtk::Image.new("pactk.jpg")
@image_box = Gtk::EventBox.new.add(image)

I copied from here:
http://lists.sourceforge.jp/mailman/arc … 00156.html


Markku

Offline

#6 2006-04-12 06:04:46

rasat
Forum Fellow
From: Finland, working in Romania
Registered: 2002-12-27
Posts: 2,293
Website

Re: Ruby+Glade - howto get an image in GtkImage widget?

Got the help from linuxquestions.org
http://www.linuxquestions.org/questions … p?t=433641

@glade = GladeXML.new(path_or_data, root, domain, localedir, flag) {|handler| method(handler)} 

@image_box = @glade["image_pkg"]

    ev_box = Gtk::EventBox.new
    ev_box.add(Gtk::Image.new("test.jpg"))

@image_box.add(ev_box).show_all

The "image_pkg" I changed to a GtkVBox widget instead of GtkImage.


Markku

Offline

Board footer

Powered by FluxBB