The following produces a bitmap control that is one third the window size in each direction, at the top left corner, clipping the bitmap - expected behavior.
class MyForm(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, parent=None, id=wx.ID_ANY,
title="Subclass BitmapCTRL Test", size=(WIDTH,HEIGHT))
self.bitmap = wx.Bitmap.FromRGBA(WIDTH//2,HEIGHT//2, 0xFF,0xFF,0xFF ,wx.ALPHA_OPAQUE)
self.bitmapCTRL = MyBitmap(parent = self,bitmap = self.bitmap,
size=(WIDTH//3,HEIGHT//3))
def CreateSizers(self):
self.mainSizer = wx.StaticBoxSizer(wx.HORIZONTAL, self)
self.SetSizer(self.mainSizer)
def Arrange(self):
self.mainSizer.Add(self.bitmapCTRL)
The following code, identical to the first except for the indicated “wx.EXPAND” flag, produces a bitmap control that is half the size of the frame horizontally, one third the size of the frame vertically, and centered. The size is expected, as the Sizer has a wx.HORIZONTAL orientation. The centering is unexpected. Why does this happen?
class MyForm(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, parent=None, id=wx.ID_ANY,
title="Subclass BitmapCTRL Test", size=(WIDTH,HEIGHT))
self.bitmap = wx.Bitmap.FromRGBA(WIDTH//2,HEIGHT//2, 0xFF,0xFF,0xFF ,wx.ALPHA_OPAQUE)
self.bitmapCTRL = MyBitmap(parent = self,bitmap = self.bitmap,
size=(WIDTH//3,HEIGHT//3))
def CreateSizers(self):
self.mainSizer = wx.StaticBoxSizer(wx.HORIZONTAL, self)
self.SetSizer(self.mainSizer)
def Arrange(self):
self.mainSizer.Add(self.bitmapCTRL, wx.EXPAND)