You are not logged in.
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
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
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
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
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
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