Tranparency on button with image?

How do I apply .setTransparency(TransparencyAttrib.MAlpha) to an image on a DirectButton??

Using OnscreenImage it looks like this:

self.myImage=OnscreenImage(image = "img/can-icon.png", pos = (0, 0, 0))

I have tried this:

But since self.button[‘image’] only contains the path for the image it does not work.

Normally, button.setTransparency() would be sufficient, since the onscreen image would inherit its transparency state from the button.

I bet you have already successfully applied transparency, but you don’t realize you have, because the button itself creates a gray background card by default, which can make it look like your image is not transparent. This confuses a lot of people.

Try creating your button with the parameter relief = None.


Thanks a lot for the help :slight_smile: