Round button/Transparent background

Hi,

I was delighted to see that wx.Button now supports bitmaps in python
2.9.x.

I want to use rounded buttons instead of square ones.
My bitmaps are png format, a rounded btn image on a transparent
square background.

When I use wx.button and set a bitmap to it, the button is square with
my image in it.
Is there a way to get rid of the square background or make it
transparent?

I also tried using the wx.lib.buttons' generic bitmap button instead
but also the transparent square background of the native png image
becomes a shade of white when I convert it to bitmap so I can use it
with the button.

In this setting again, what can I do to keep the background
transparent so the button looks rounded.

Thank you
VC

I tried using a shaped bitmap button, the button looks rounded but
there is still a thin rim around the button that looks like a shade of
white. I want the button to blend with the background panel picture
and so this thin rim makes it stick out. :frowning:
Anyway to make the button background transparent?

VC

···

On Apr 22, 1:21 pm, VC <napoleon...@gmail.com> wrote:

Hi,

I was delighted to see that wx.Button now supports bitmaps in python
2.9.x.

I want to use rounded buttons instead of square ones.
My bitmaps are png format, a rounded btn image on a transparent
square background.

When I use wx.button and set a bitmap to it, the button is square with
my image in it.
Is there a way to get rid of the square background or make it
transparent?

I also tried using the wx.lib.buttons' generic bitmap button instead
but also the transparent square background of the native png image
becomes a shade of white when I convert it to bitmap so I can use it
with the button.

In this setting again, what can I do to keep the background
transparent so the button looks rounded.

Thank you
VC

If i get the bitmap size and then set the SBitmapButton sise to bitmap
size[0]-2, and bitmap size[1] -2 i get rid of that rim lol, but i am
still interested to know if there is another way.
Thank you.

Here is the code:
class MyTestFrame(wx.Frame):
    def __init__(self, parent, id, title, pos, size):
        wx.Frame.__init__(self, parent, id, title, pos, size)
        self.panel = wx.Panel(self, -1, style = wx.TRANSPARENT_WINDOW)
        img1 = wx.Bitmap('C:\\Users\\Von_Clausewitz\\Desktop\
\Programing\\TestEditor\\src\\button_cancel.png', wx.BITMAP_TYPE_PNG)
        img2 = wx.Bitmap ('C:\\Users\\Von_Clausewitz\\Desktop\
\Programing\\TestEditor\\src\\button_ransom.png', wx.BITMAP_TYPE_ANY)
        asize = img1.GetSize()
        self.Btn = SBitmapButton(self.panel, -1,None, pos = (50,50),
size = (asize[0]-2, asize[1]-2))
        self.panel.SetBackgroundColour('grey')
        self.Btn.SetBitmapLabel(img1)
        self.Btn.SetUseFocusIndicator(False)
        self.Btn.SetBitmapSelected(img2)

class MyApp(wx.App):
    def OnInit(self):
        self.frame = MyTestFrame(None, -1, 'Test Btn', (300,300),
(300,300))
        self.frame.Show()
        return True

if __name__ == "__main__":
    app = MyApp()
    app.MainLoop()

···

On Apr 22, 4:03 pm, VC <napoleon...@gmail.com> wrote:

On Apr 22, 1:21 pm, VC <napoleon...@gmail.com> wrote:

> Hi,

> I was delighted to see that wx.Button now supports bitmaps in python
> 2.9.x.

> I want to use rounded buttons instead of square ones.
> My bitmaps are png format, a rounded btn image on a transparent
> square background.

> When I use wx.button and set a bitmap to it, the button is square with
> my image in it.
> Is there a way to get rid of the square background or make it
> transparent?

> I also tried using the wx.lib.buttons' generic bitmap button instead
> but also the transparent square background of the native png image
> becomes a shade of white when I convert it to bitmap so I can use it
> with the button.

> In this setting again, what can I do to keep the background
> transparent so the button looks rounded.

> Thank you
> VC

I tried using a shaped bitmap button, the button looks rounded but
there is still a thin rim around the button that looks like a shade of
white. I want the button to blend with the background panel picture
and so this thin rim makes it stick out. :frowning:
Anyway to make the button background transparent?

VC