View Single Post
Posts: 25 | Thanked: 8 times | Joined on Feb 2008
#1
I'm trying to create a button that is the shape of its image (instead of rectangular). From my research, it seems that the way to do this is with shape_combine_mask, which makes all the non-mask parts of the button transparent and thus displays in the desired shape.

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?

Thanks!