Question about wx.BitmapButton and sizers...

I have a row of BitmapButtons that I’m putting into a box sizer, and I’d like them to have the 3d border, aka style=wx.BU_AUTODRAW. The problem is that the 3d border expands beyond the size of the bitmap button, which looks bad.

Is there some way to specify a maximum size for the button border? Or some other clever way to give feedback when the button is clicked?

Some code. In the below example, the background border of pic2 expands beyond the size of the graphic.

    panel = wx.Panel(self, -1, style = wx.SIMPLE_BORDER)
    box = wx.BoxSizer(wx.HORIZONTAL) :

    pic1 = wx.BitmapButton(panel, -1, wx.Bitmap('utils/assets/eye-icon.png'), style=wx.NO_BORDER

)
pic2 = wx.BitmapButton(panel, -1, wx.Bitmap(‘utils/assets/eye-icon.png’), style=wx.BU_AUTODRAW | wx.BU_EXACTFIT) # with 3d border
pic3 = wx.BitmapButton(panel, -1, wx.Bitmap(‘utils/assets/eye-
icon.png’), style=wx.NO_BORDER)

    box.Add(pic1, 1, wx.ALIGN_CENTER)
    box.Add(pic2, 1, wx.ALIGN_CENTER)
    box.Add(pic3, 1, wx.ALIGN_CENTER)
   
    panel.SetSizer(box)

    self.Centre()

Alec Bennett wrote:

I have a row of BitmapButtons that I'm putting into a box sizer, and I'd like them to have the 3d border, aka style=wx.BU_AUTODRAW. The problem is that the 3d border expands beyond the size of the bitmap button, which looks bad.

Is there some way to specify a maximum size for the button border? Or some other clever way to give feedback when the button is clicked?

No, you either get the platform border as-is, or you need to provide your own bitmaps for the various states. There is also the generic button classes in wx.lib.buttons.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!