Hi I’m sort new to wxPython and still in the process of learning. I’m trying to make a bitmap button using a particular image like this for example: http://i.min.us/idk3Uy.png
The catch is I want to retain the original shape of the image in the button, like a circular button for example instead of a rectangular one (which is default).
I want to know how to do that exactly or if it is possible to do that at all; I did take a look at the documentation and I’ve found the style constant wx.BU_EXACTFIT removes the unnecessary borders…but it’s still not in the desirable shape that I want it to be.
Thanks.
You’re probably going to have to implement a custom control for this. I’ve done my fair share of custom wxPython controls, so I went ahead and wrote a
ShapedButtonclass for you. =)To run this demo, you just need three images:
The three images are used depending on the state of the button. Only the “normal” one is required, but you probably want to at least provide “normal” and “pressed” so the user gets feedback when clicking.
The control only responds to clicks in non-transparent areas of the normal bitmap. It properly fires the
EVT_BUTTONevent when clicked and released.Enjoy!