I can't seem to figure out why my bitmap button looks like a standard button with the image in the middle. I've followed the examples and the wxPython constructor methods and nothing seems to change or match what I see in the examples and tutorials. Here is my constructor:
bmp = wx.Bitmap("plus-circle.png", wx.BITMAP_TYPE_ANY)
self.imgButton = wx.BitmapButton(self, bitmap=bmp)
self.imgButton.Bind(wx.EVT_BUTTON, self.addCategory)
catSizer.Add(self.txtCategory, 0, wx.ALL, 5)
catSizer.Add(self.cmbCategory, 1, wx.ALL, 5)
catSizer.Add(self.imgButton, 2, wx.ALL, 5)
And this is how it is shown in my 'panel' as it's part of a tabbed window:
How can I just have the image as my button without all the extra border around it? I did try the GetHeight, GetWidth, methods, plus DefaultSize, etc, but nothing seems two work.
I'm running Python 3.6 on Mac OS Mojave.
Thanks!
When you add the button to the sizer, you are instructing it to change the proportion to 2.
catSizer.Add(self.imgButton, 2, wx.ALL, 5)
Sizer.Add(window, proportion=0, flag=0, border=0, userData=None)
proportion
-
this parameter is used in wx.BoxSizer to indicate if a child of a sizer can change its size in the main orientation of the wx.BoxSizer - where 0 stands for not changeable and a value of more than zero is interpreted relative to the value of other children of the same wx.BoxSizer. For example, you might have a horizontal wx.BoxSizer with three children, two of which are supposed to change their size with the sizer. Then the two stretchable windows would get a value of 1 each to make them grow and shrink equally with the sizer’s horizontal dimension.
Change your code to the following:
catSizer.Add(self.imgButton, 0, wx.ALL, 5)
that should fix your problem.