View Single Post
Posts: 87 | Thanked: 98 times | Joined on Oct 2007 @ Austria
#16
Originally Posted by SpiritGeek View Post
However, I'm not getting anywhere in actually making it work. Here's my best guess (in Python):

Code:
PixBuf = gtk.gdk.pixbuf_new_from_file("image.png")
Image = gtk.image_new_from_pixbuf(PixBuf)
Button = gtk.Button()
Button.set_image(Image)
MapMask = PixBuf.render_pixmap_and_mask()
Mask = MapMask[1]
self.add(Button)
Button.shape_combine_mask(Mask, 0, 0)
Button.show()
self.show()
This gets me a button with the correct image, but no masking. Can anybody spot what I'm doing wrong?
I found that shape_combine_mask() works, but you have to apply it to the container, not the button (which I think is transparent by default).

So replacing Button.shape_combine_mask(Mask, 0, 0) with self.shape_combine_mask(Mask, 0, 0) should do the trick, I think.