Re: how ot create a button with a png image in it??



On Sunday, April 25, 2004, at 11:44 AM, Bruno Boettcher wrote:

but i looked through the docu found out how to load xpm's and such stuff, but couldn't get a hint on how lo actually load a png image into a button???

depends on how you want to do it.

1) put a Gtk2::Image into the button, with normal widget layout controls (the button is just a container).

2) create a new stock item that contains your image, then use Gtk2::Button->new_from_stock ($newstockid);


both methods require you to get the image data from someplace:

a) load from files (e.g., Gtk2::Image->new_from_file() or Gtk2::Gdk::Pixbuf->new_from_file()).

b) load from inlined image data (mostly Gtk2::Gdk::Pixbuf->new_from_xpm_data() and friends)


check the Gtk2/examples directory, i believe most, if not all, of these methods are used in there.


i recommend 2+b, personally; it's more work, but your code requires no external data, and the stock mechanism does a lot of work for you (scaling images, installing accelerators and mnemonics, etc).

--
I bring the rock, and provided it is fiscally responsible, I will bring the funk as well. And that's fo-shizzle.
        -- Saturday Night Live




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