def __init__(self, *args, **kwargs): """ :param parent: (wx.Window) parent window :param id: (int) button id (optional) :param bitmap: (wx.Bitmap) default button face. Use `SetBitmaps` to set the other faces (e.g. hover, active) :param pos: (int, int)) button position :param size: (int, int) button size :param background_parent: (wx.Window) any parent higher up in the hierarchy from which to pick the background colour. (optional) :param label_delta: (int) the number of pixels to move button text down and to the right when it is pressed, to create an indentation effect. (This is used by subclasses that allow text to be displayed) """ kwargs['style'] = wx.NO_BORDER self.labelDelta = kwargs.pop('label_delta', 0) self.background_parent = kwargs.pop('background_parent', None) # Fit the bmp if needed # Resizing should always be minimal, so distortion is minimum # If the bmp arg is provided (which is the 3rd one: parent, id, bmp) bmp = args[2] if len(args) >= 3 else kwargs.get('bitmap', None) size = args[4] if len(args) >= 5 else kwargs.get('size', None) if bmp: if size and size != (-1, -1): args = list(args) # Resize and replace original bmp if len(args) >= 3: args[2] = resize_bmp(size, bmp) else: kwargs['bitmap'] = resize_bmp(size, bmp) else: # Set the size of the button to match the bmp if len(args) >= 5: args[4] = bmp.GetSize() else: kwargs['size'] = bmp.GetSize() GenBitmapToggleButton.__init__(self, *args, **kwargs) if self.background_parent: self.SetBackgroundColour( self.background_parent.GetBackgroundColour() ) else: self.SetBackgroundColour(self.GetParent().GetBackgroundColour()) self.bmpHover = None self.bmpSelectedHover = None self.hovering = False self.Bind(wx.EVT_ENTER_WINDOW, self.OnEnter) self.Bind(wx.EVT_LEAVE_WINDOW, self.OnLeave)
def __init__( self, parent, id=-1, bitmap=wx.NullBitmap, pos=wx.DefaultPosition, size=wx.DefaultSize, style=0, validator=wx.DefaultValidator, name="bitmaptogglebutton", ): GenBitmapToggleButton.__init__(self, parent, id, bitmap, pos, size, style, validator, name)
def __init__(self, parent, label_bitmap=None, selected_bitmap=None, toggled=False): # An image toggle button GenBitmapToggleButton.__init__(self, parent, id=-1, bitmap=None) if label_bitmap <> None: mask = wx.Mask(label_bitmap, wx.BLUE) label_bitmap.SetMask(mask) self.SetBitmapLabel(label_bitmap) if selected_bitmap <> None: mask = wx.Mask(selected_bitmap, wx.BLUE) selected_bitmap.SetMask(mask) self.SetBitmapSelected(selected_bitmap) self.SetToggle(toggled) self.SetInitialSize()