Beispiel #1
0
    def __init__(self, parent, size=(21, 21), value=wx.BLACK):
        w, h = size[0] - 5, size[1] - 5
        GenBitmapButton.__init__(self, parent, wx.ID_ANY, wx.Bitmap(w, h),
                                 size=size)
        self.SetBezelWidth(1)

        self.parent = parent
        self.SetValue(value)

        self.parent.Bind(wx.EVT_BUTTON, self.OnClick, self)
 def __init__(self, parent, ID=-1, bitmap=wx.NullBitmap,
              pos = wx.DefaultPosition, size = wx.DefaultSize,
              style = 0, validator = wx.DefaultValidator,
              name = "genbutton"):
     self.bitmap = bitmap
     GenBitmapButton.__init__(self, parent, ID, bitmap, pos, size, style, validator, name)
     self.SetBezelWidth(0)
     self.useFocusInd = False
     self.SetBestSize(None)
     self.Bind(wx.EVT_ENTER_WINDOW, self.ButtonOnMouseEnter)
     self.Bind(wx.EVT_LEAVE_WINDOW, self.ButtonOnMouseLeave)
Beispiel #3
0
 def __init__(self, parent, ID=-1, bitmap=wx.NullBitmap,
              pos = wx.DefaultPosition, size = wx.DefaultSize,
              style = 0, validator = wx.DefaultValidator,
              name = "genbutton"):
     self.bitmap = bitmap
     GenBitmapButton.__init__(self, parent, ID, bitmap, pos, size, style, validator, name)
     self.SetBezelWidth(0)
     self.useFocusInd = False
     self.SetBestSize(None)
     self.Bind(wx.EVT_ENTER_WINDOW, self.ButtonOnMouseEnter)
     self.Bind(wx.EVT_LEAVE_WINDOW, self.ButtonOnMouseLeave)
Beispiel #4
0
    def __init__(self, parent, size=(21, 21), value=wx.BLACK):
        w, h = size[0] - 5, size[1] - 5
        GenBitmapButton.__init__(self,
                                 parent,
                                 wx.ID_ANY,
                                 wx.Bitmap(w, h),
                                 size=size)
        self.SetBezelWidth(1)

        self.parent = parent
        self.SetValue(value)

        self.parent.Bind(wx.EVT_BUTTON, self.OnClick, self)
Beispiel #5
0
    def __init__(self, *args, **kwargs):
        """ If the background_parent keyword argument is provided, it will be
        used to determine the background colour of the button. Otherwise, the
        direct parent will be used.

        :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)

        """

        if kwargs.has_key('style'):
            kwargs['style'] |= wx.NO_BORDER
        else:
            kwargs['style'] = wx.NO_BORDER

        self.background_parent = kwargs.pop('background_parent', None)
        self.labelDelta = kwargs.pop('label_delta', 0)

        # 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()

        GenBitmapButton.__init__(self, *args, **kwargs)

        if self.background_parent:
            self.SetBackgroundColour(
                self.background_parent.GetBackgroundColour()
            )
        else:
            self.SetBackgroundColour(self.GetParent().GetBackgroundColour())

        self.bmpHover = None
        self.hovering = False

        self.Bind(wx.EVT_ENTER_WINDOW, self.OnEnter)
        self.Bind(wx.EVT_LEAVE_WINDOW, self.OnLeave)
Beispiel #6
0
 def __init__(self, parent, id, bitmap, pos, size, style):
     GenBitmapButton.__init__(self, parent, id, bitmap, pos, size, style)
     self.bgcolor = wx.Brush(wx.WHITE)