Ruby Forum Ruby-Gnome 2 > Multiple images in a Gtk::Image

Posted by Marc Heiler (shevegen)
on 29.07.2008 18:27
Hi,

right now I can use an image like so:

  image = Gtk::Image.new(location)
  image.set_padding(4,0) # left-right axis, top-down axis
  self.set_image(image)

And right next of that image I can display text (both is part of a
button).

Is there a way to set multiple images easily too?
For example I would like to set multiple, little icons of "monsters"
right before the text appears, and I want the whole "line" to behave
like
a button.
Posted by Marc Heiler (shevegen)
on 29.07.2008 18:28
Sorry, i forgot to mention - i was speaking about subclassing
a button like so

class ColouredButton < Gtk::Button



And all the Gtk buttons have this ability

  self.set_image(image)
Posted by André Wagner (andre_nho)
on 29.07.2008 18:40
(Received via mailing list)
> Is there a way to set multiple images easily too?
> For example I would like to set multiple, little icons of "monsters"
> right before the text appears, and I want the whole "line" to behave
> like
> a button.

A Gtk::Button is also a container, so you can put a Gtk::HBox or a 
Gtk::Table inside of it.

Such as:

button = Gtk::Button.new
hbox = Gtk::HBox.new
hbox.pack_start(Gtk::Image.new(...))
hbox.pack_start(Gtk::Image.new(...))
hbox.pack_start(Gtk::Image.new(...))
hbox.pack_start(Gtk::Label.new('My button'))
button << hbox
button.show_all

Regards,

André 

--
Lamentação sem gratidão é murmuração. (Howard Hendricks)
Posted by Marc Heiler (shevegen)
on 29.07.2008 23:29
I like the idea. It is simple enough, thanks!