Re: [gtkmm] how to put an image into a button



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

cedric wrote:

| hi !
|
| i have to put an image into a button.
| I saw in the API i have to use stockID but i would like to use the image
| alone without the text under it.
|
| If someone could help me..
| thks

A button is actually a container, so you can put any widget you like
inside one (I wouldn't recommend putting another button in there
though!). The normal button constructor simply packs a label into the
button, but you can put anything you like in instead.

So to do this, make an empty button using the default constructor (not
the version with the label or the stock ID), then make the widget to put
in it (such as a Gtk::Image, or perhaps a Gtk::VBox with some things
packed in it if you want more than one thing), then use the button's
add() method to add the widget to the button, and voila, you have a
button with a whatever you want on it.

I'm afraid I can't remember how to pull the icon for a stock object and
turn it into a Gtk::Image, but I know it's possible because we did
something similar in the Stock Browser demo (but I wrote that one so
long ago I can't remember how I did it).
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (Darwin)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFA1rCn0UvYjCBpIlARAtg0AJ41AUDOiUoI2CXB09p3QHQSGXORpgCffiM/
6rO1H1GsBwxe/A7M3S4HyEg=
=8Bc4
-----END PGP SIGNATURE-----




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]