コード例 #1
0
ファイル: Button.py プロジェクト: alvii147/MangoUI
    def setColors(self,
                  primaryColor=None,
                  secondaryColor=None,
                  parentBackgroundColor=None):
        '''Set button colors.

        Parameters:
            primaryColor (QColor obj/RGBA tuple/RGBA 32-bit unsigned int/RGBA str/HEX str): normal text color and background color on hover
            secondaryColor (QColor obj/RGBA tuple/RGBA 32-bit unsigned int/RGBA str/HEX str): normal background color and the text color on hover
            parentBackgroundColor (QColor obj/RGBA tuple/RGBA 32-bit unsigned int/RGBA str/HEX str): parent element's background color used for minimize effect on click 

        Returns:
            None
        '''

        if primaryColor != None:
            self.primaryColor = to_RGBAtuple(primaryColor)

        if secondaryColor != None:
            self.secondaryColor = to_RGBAtuple(secondaryColor)

        if parentBackgroundColor != None:
            self.parentBackgroundColor = to_RGBAtuple(parentBackgroundColor)

        self.setupColors()
        self.renderStyleSheet()
コード例 #2
0
    def __init__(
            self,
            parent=None,
            textColor=(21, 21, 21, 255),
            backgroundColor=(245, 177, 66, 255),
            backgroundColorOnHover=(249, 205, 134, 255),
            fontFamily='Verdana',
            fontSize=10,
            fontWeight='normal',
            borderStyle='solid',
            borderColor=(21, 21, 21, 255),
            borderWidth=1,
            borderRadius=2,
    ):
        '''Create new TagBox object.

        Parameters:
            parent (QWidget obj/QLayout obj): parent element
            textColor (QColor obj/RGBA tuple/RGBA 32-bit unsigned int/RGBA str/HEX str): tag text color
            backgroundColor (QColor obj/RGBA tuple/RGBA 32-bit unsigned int/RGBA str/HEX str): tag background color
            backgroundColorOnHover (QColor obj/RGBA tuple/RGBA 32-bit unsigned int/RGBA str/HEX str): tag background color on mouse hover
            fontFamily (str): name of font family
            fontSize (int): font size
            fontWeight (str): font weight
            borderStyle (str): tag border style
            borderColor (QColor obj/RGBA tuple/RGBA 32-bit unsigned int/RGBA str/HEX str): tag border color
            borderWidth (int): tag border width
            borderRadius (int): tag border radius

        Returns:
            TagBox obj
        '''

        if parent:
            super().__init__(parent)
        else:
            super().__init__()

        self.textColor = to_RGBAtuple(textColor)
        self.backgroundColor = to_RGBAtuple(backgroundColor)
        self.backgroundColorOnHover = to_RGBAtuple(backgroundColorOnHover)

        self.fontFamily = fontFamily
        self.fontSize = fontSize
        self.fontWeight = fontWeight

        self.borderStyle = borderStyle
        self.borderColor = to_RGBAtuple(borderColor)
        self.borderWidth = borderWidth
        self.borderRadius = borderRadius

        self.tagList = []

        self.flowLayout = FlowLayout()
        self.setLayout(self.flowLayout)

        self.initTagBox()
コード例 #3
0
ファイル: Button.py プロジェクト: alvii147/MangoUI
    def __init__(
        self,
        parent=None,
        primaryColor=(21, 21, 21, 255),
        secondaryColor=(245, 177, 66, 255),
        parentBackgroundColor=(240, 240, 240, 255),
        fontFamily='Verdana',
        fontSize=8,
        fontWeight='normal',
        borderStyle='solid',
        borderWidth=1,
        borderRadius=2,
    ):
        '''Create new Button object.

        Parameters:
            parent (QWidget obj/QLayout obj): parent element
            primaryColor (QColor obj/RGBA tuple/RGBA 32-bit unsigned int/RGBA str/HEX str): normal text color and background color on hover
            secondaryColor (QColor obj/RGBA tuple/RGBA 32-bit unsigned int/RGBA str/HEX str): normal background color and the text color on hover
            parentBackgroundColor (QColor obj/RGBA tuple/RGBA 32-bit unsigned int/RGBA str/HEX str): parent element's background color used for minimize effect on click 
            fontFamily (str): name of font family
            fontSize (int): font size
            fontWeight (str): font weight
            borderStyle (str): border style
            borderWidth (int): border width
            borderRadius (int): border radius

        Returns:
            Button obj
        '''

        if parent:
            super().__init__(parent)
        else:
            super().__init__()

        self.setCursor(QCursor(Qt.CursorShape.PointingHandCursor))

        self.primaryColor = to_RGBAtuple(primaryColor)
        self.secondaryColor = to_RGBAtuple(secondaryColor)
        self.parentBackgroundColor = to_RGBAtuple(parentBackgroundColor)

        self.setupColors()

        self.fontFamily = fontFamily
        self.fontSize = fontSize
        self.fontWeight = fontWeight

        self.borderStyle = borderStyle
        self.borderWidth = borderWidth
        self.borderRadius = borderRadius

        self.renderStyleSheet()
コード例 #4
0
ファイル: Button.py プロジェクト: alvii147/MangoUI
 def onHover(self, color):
     if self.animation.direction() == QAbstractAnimation.Direction.Forward:
         self.color = self.primaryColor
     else:
         self.color = self.secondaryColor
     self.backgroundColor = to_RGBAtuple(color)
     self.renderStyleSheet()
コード例 #5
0
ファイル: Canvas.py プロジェクト: alvii147/MangoUI
    def setPenColor(self, color):
        '''Set pen color.

        Parameters:
            color (QColor obj/RGBA tuple/RGBA 32-bit unsigned int/RGBA str/HEX str): pen color

        Returns:
            None
        '''

        self.color = to_RGBAtuple(color)