# Multiple images in a Gtk::Image

**URL:** <https://www.ruby-forum.com/t/multiple-images-in-a-gtk-image/144439>\
**Category:** Ruby-Gnome 2\
**Created:** [July 29, 2008, 6:27pm UTC](https://www.ruby-forum.com/t/multiple-images-in-a-gtk-image/144439 "2008-07-29T18:27:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![quik77](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/q/dec6dc/32.png) [@quik77](https://www.ruby-forum.com/u/quik77)\
**Post date:** [July 29, 2008, 6:27pm UTC](https://www.ruby-forum.com/t/multiple-images-in-a-gtk-image/144439/1 "2008-07-29T18:27:30Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![quik77](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/q/dec6dc/32.png) [@quik77](https://www.ruby-forum.com/u/quik77)\
**Post date:** [July 29, 2008, 6:28pm UTC](https://www.ruby-forum.com/t/multiple-images-in-a-gtk-image/144439/2 "2008-07-29T18:28:27Z")

</div>

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)

---

<div class="post-metadata">

**Author:** ![quik77](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/q/dec6dc/32.png) [@quik77](https://www.ruby-forum.com/u/quik77)\
**Post date:** [July 29, 2008, 11:29pm UTC](https://www.ruby-forum.com/t/multiple-images-in-a-gtk-image/144439/3 "2008-07-29T23:29:40Z")

</div>

I like the idea. It is simple enough, thanks!

---

<div class="post-metadata">

**Author:** ![quik77](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/q/dec6dc/32.png) [@quik77](https://www.ruby-forum.com/u/quik77)\
**Post date:** [July 29, 2008, 6:40pm UTC](https://www.ruby-forum.com/t/multiple-images-in-a-gtk-image/144439/4 "2008-07-29T18:40:30Z")

</div>

> 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)
