Example #1
0
    def get_color(self, state, cx, cy, rad):
        c = self._get_color(state)

        gradient = QRadialGradient(cx, cy, rad)  # (10, 10, 10, 10)
        gradient.setColorAt(0, Qt.white)
        gradient.setColorAt(1, c)
        brush = QBrush(gradient)
        return brush
Example #2
0
    def __init__(self, parent=None):
        QToolButton.__init__(self, parent)

        self.badge_counter = 0x00
        self.badge_size = 25

        self.redGradient = QRadialGradient(0.0, 0.0, 17.0, self.badge_size - 3,
                                           self.badge_size - 3)
        self.redGradient.setColorAt(0.0, QColor(0xe0, 0x84, 0x9b))
        self.redGradient.setColorAt(0.5, QColor(0xe9, 0x34, 0x43))
        self.redGradient.setColorAt(1.0, QColor(0xdc, 0x0c, 0x00))
Example #3
0
 def __init__(self, parent=None, ast=None):
     ''' Create the INPUT symbol '''
     ast = ast or ogAST.Input()
     self.branch_entrypoint = None
     if not ast.pos_y and parent:
         # Make sure the item is placed below its parent
         ast.pos_y = parent.y() + parent.boundingRect().height() + 10
     super(Input, self).__init__(parent, text=ast.inputString,
             x=ast.pos_x, y=ast.pos_y, hyperlink=ast.hyperlink)
     self.set_shape(ast.width, ast.height)
     gradient = QRadialGradient(50, 50, 50, 50, 50)
     gradient.setColorAt(0, QColor(255, 240, 170))
     gradient.setColorAt(1, Qt.white)
     self.setBrush(QBrush(gradient))
     self.terminal_symbol = False
     self.parser = ogParser
     if ast.comment:
         Comment(parent=self, ast=ast.comment)
Example #4
0
    def __init__(self, parent=None):
        QToolButton.__init__(self, parent)

        self.badge_counter = 0x00
        self.badge_size = 25

        self.redGradient = QRadialGradient(0.0, 0.0, 17.0, self.badge_size - 3,
								self.badge_size - 3)
        self.redGradient.setColorAt(0.0, QColor(0xe0, 0x84, 0x9b))
        self.redGradient.setColorAt(0.5, QColor(0xe9, 0x34, 0x43))
        self.redGradient.setColorAt(1.0, QColor(0xdc, 0x0c, 0x00))
Example #5
0
    def __init__(
        self,
        icon=None,
        text=None,
        parent=None,
    ):
        if icon:
            QPushButton.__init__(self, icon, text, parent)
        elif text:
            QPushButton.__init__(self, text, parent)
        else:
            QPushButton.__init__(self, parent)

        self.badge_counter = 0x00
        self.badge_size = 50

        self.redGradient = QRadialGradient(0.0, 0.0, 17.0, self.badge_size - 3,
                                           self.badge_size - 3)
        self.redGradient.setColorAt(0.0, QColor(0xe0, 0x84, 0x9b))
        self.redGradient.setColorAt(0.5, QColor(0xe9, 0x34, 0x43))
        self.redGradient.setColorAt(1.0, QColor(0xdc, 0x0c, 0x00))
Example #6
0
    def get_color(self, state, cx, cy, rad):
        c = self._get_color(state)

        gradient = QRadialGradient(cx, cy, rad)  # (10, 10, 10, 10)
        gradient.setColorAt(0, Qt.white)
        gradient.setColorAt(1, c)
        brush = QBrush(gradient)
        return brush
Example #7
0
    def __init__(
        self,
        icon=None,
        text=None,
        parent=None,
        ):
        if icon:
            QPushButton.__init__(self, icon, text, parent)
        elif text:
            QPushButton.__init__(self, text, parent)
        else:
            QPushButton.__init__(self, parent)

        self.badge_counter = 0x00
        self.badge_size = 50

        self.redGradient = QRadialGradient(0.0, 0.0, 17.0, self.badge_size - 3,
                self.badge_size - 3)
        self.redGradient.setColorAt(0.0, QColor(0xe0, 0x84, 0x9b))
        self.redGradient.setColorAt(0.5, QColor(0xe9, 0x34, 0x43))
        self.redGradient.setColorAt(1.0, QColor(0xdc, 0x0c, 0x00))
Example #8
0
 def __init__(self, parent=None, ast=None):
     ''' Create the INPUT symbol '''
     ast = ast or ogAST.Input()
     self.branch_entrypoint = None
     if not ast.pos_y and parent:
         # Make sure the item is placed below its parent
         ast.pos_y = parent.y() + parent.boundingRect().height() + 10
     super(Input, self).__init__(parent,
                                 text=ast.inputString,
                                 x=ast.pos_x,
                                 y=ast.pos_y,
                                 hyperlink=ast.hyperlink)
     self.set_shape(ast.width, ast.height)
     gradient = QRadialGradient(50, 50, 50, 50, 50)
     gradient.setColorAt(0, QColor(255, 240, 170))
     gradient.setColorAt(1, Qt.white)
     self.setBrush(QBrush(gradient))
     self.terminal_symbol = False
     self.parser = ogParser
     if ast.comment:
         Comment(parent=self, ast=ast.comment)
Example #9
0
class QBadgeButton(QPushButton):

    def __init__(
        self,
        icon=None,
        text=None,
        parent=None,
        ):
        if icon:
            QPushButton.__init__(self, icon, text, parent)
        elif text:
            QPushButton.__init__(self, text, parent)
        else:
            QPushButton.__init__(self, parent)

        self.badge_counter = 0x00
        self.badge_size = 50

        self.redGradient = QRadialGradient(0.0, 0.0, 17.0, self.badge_size - 3,
                self.badge_size - 3)
        self.redGradient.setColorAt(0.0, QColor(0xe0, 0x84, 0x9b))
        self.redGradient.setColorAt(0.5, QColor(0xe9, 0x34, 0x43))
        self.redGradient.setColorAt(1.0, QColor(0xdc, 0x0c, 0x00))

    def setSize(self, size):
        self.badge_size = size

    def setCounter(self, counter):
        self.badge_counter = counter
        self.update()

    def getCounter(self):
        return self.badge_counter

    def paintEvent(self, event):
        QPushButton.paintEvent(self, event)
        p = QPainter(self)
        p.setRenderHint(QPainter.TextAntialiasing)
        p.setRenderHint(QPainter.Antialiasing)

        if self.badge_counter > 0x00:
            point = self.rect().topRight()
            self.drawBadge(
                p,
                point.x() - self.badge_size - 1,
                point.y() + 1,
                self.badge_size,
                str(self.badge_counter),
                QBrush(self.redGradient),
                )

    def fillEllipse(
        self,
        painter,
        x,
        y,
        size,
        brush,
        ):
        path = QPainterPath()
        path.addEllipse(x, y, size, size)
        painter.fillPath(path, brush)

    def drawBadge(
        self,
        painter,
        x,
        y,
        size,
        text,
        brush,
        ):
        painter.setFont(QFont(painter.font().family(), 11, QFont.Bold))

        while size - painter.fontMetrics().width(text) < 10:
            pointSize = painter.font().pointSize() - 1
            weight = (QFont.Normal if pointSize < 8 else QFont.Bold)
            painter.setFont(QFont(painter.font().family(),
                            painter.font().pointSize() - 1, weight))

        shadowColor = QColor(0x00, 0x00, 0x00, size)
        self.fillEllipse(painter, x + 1, y, size, shadowColor)
        self.fillEllipse(painter, x - 1, y, size, shadowColor)
        self.fillEllipse(painter, x, y + 1, size, shadowColor)
        self.fillEllipse(painter, x, y - 1, size, shadowColor)

        painter.setPen(QPen(Qt.white, 2))
        self.fillEllipse(painter, x, y, size - 3, brush)
        painter.drawEllipse(x, y, size - 3, size - 3)

        painter.setPen(QPen(Qt.white, 1))
        painter.drawText(
            x,
            y,
            size - 2,
            size - 2,
            Qt.AlignCenter,
            text,
            )
Example #10
0
 def testAllInt(self):
     grad = QRadialGradient(1, 2, 5, 3, 4)
     self._assertValues(grad)
Example #11
0
class QBadgeButton(QPushButton):
    def __init__(
        self,
        icon=None,
        text=None,
        parent=None,
    ):
        if icon:
            QPushButton.__init__(self, icon, text, parent)
        elif text:
            QPushButton.__init__(self, text, parent)
        else:
            QPushButton.__init__(self, parent)

        self.badge_counter = 0x00
        self.badge_size = 50

        self.redGradient = QRadialGradient(0.0, 0.0, 17.0, self.badge_size - 3,
                                           self.badge_size - 3)
        self.redGradient.setColorAt(0.0, QColor(0xe0, 0x84, 0x9b))
        self.redGradient.setColorAt(0.5, QColor(0xe9, 0x34, 0x43))
        self.redGradient.setColorAt(1.0, QColor(0xdc, 0x0c, 0x00))

    def setSize(self, size):
        self.badge_size = size

    def setCounter(self, counter):
        self.badge_counter = counter
        self.update()

    def getCounter(self):
        return self.badge_counter

    def paintEvent(self, event):
        QPushButton.paintEvent(self, event)
        p = QPainter(self)
        p.setRenderHint(QPainter.TextAntialiasing)
        p.setRenderHint(QPainter.Antialiasing)

        if self.badge_counter > 0x00:
            point = self.rect().topRight()
            self.drawBadge(
                p,
                point.x() - self.badge_size - 1,
                point.y() + 1,
                self.badge_size,
                str(self.badge_counter),
                QBrush(self.redGradient),
            )

    def fillEllipse(
        self,
        painter,
        x,
        y,
        size,
        brush,
    ):
        path = QPainterPath()
        path.addEllipse(x, y, size, size)
        painter.fillPath(path, brush)

    def drawBadge(
        self,
        painter,
        x,
        y,
        size,
        text,
        brush,
    ):
        painter.setFont(QFont(painter.font().family(), 11, QFont.Bold))

        while size - painter.fontMetrics().width(text) < 10:
            pointSize = painter.font().pointSize() - 1
            weight = (QFont.Normal if pointSize < 8 else QFont.Bold)
            painter.setFont(
                QFont(painter.font().family(),
                      painter.font().pointSize() - 1, weight))

        shadowColor = QColor(0x00, 0x00, 0x00, size)
        self.fillEllipse(painter, x + 1, y, size, shadowColor)
        self.fillEllipse(painter, x - 1, y, size, shadowColor)
        self.fillEllipse(painter, x, y + 1, size, shadowColor)
        self.fillEllipse(painter, x, y - 1, size, shadowColor)

        painter.setPen(QPen(Qt.white, 2))
        self.fillEllipse(painter, x, y, size - 3, brush)
        painter.drawEllipse(x, y, size - 3, size - 3)

        painter.setPen(QPen(Qt.white, 1))
        painter.drawText(
            x,
            y,
            size - 2,
            size - 2,
            Qt.AlignCenter,
            text,
        )
    def paintEvent(self, event):
        painter = qg.QPainter(self)
        option = qg.QStyleOption()
        option.initFrom(self)

        x = option.rect.x()
        y = option.rect.y()
        height = option.rect.height()
        width = option.rect.width()
        painter.setRenderHint(qg.QPainter.Antialiasing)

        gradient = QRadialGradient(float(width / 2), float(height / 2),
                                   float(height / 2), float(width / 2),
                                   float(height / 2))
        #################################

        alignment = (qc.Qt.AlignHCenter | qc.Qt.AlignVCenter)
        inner_gradient = QLinearGradient(0, 0, height, 0)
        inner_gradient.setColorAt(0, QColor(255, 255, 255, 35))
        inner_gradient.setColorAt(1, QColor(1, 1, 1, 100))
        gradient.setColorAt(0.0, self.col1)
        gradient.setColorAt(0.2, self.col2)
        gradient.setColorAt(0.5, self.col3)
        gradient.setColorAt(0.7, self.col4)
        gradient.setColorAt(1.0, self.col5)

        painter.setOpacity(1.0)
        painter.fillRect(x, y, width, height, gradient)

        painter.fillRect(x, y, width, height, self.MAINBRUSH)
        #painter.setOpacity(0.5)
        painter.fillRect(x, y, width, height, inner_gradient)

        painter.setBrush(self._brushClear)

        line_path = qg.QPainterPath()
        line_path.moveTo(x, height)
        line_path.lineTo(
            width,
            height,
        )
        self.penTick.setCapStyle(qc.Qt.RoundCap)
        self._pen_line.setCapStyle(qc.Qt.RoundCap)

        painter.setPen(self._pen_text)
        painter.drawPath(line_path)
        painter.setPen(self.penTick)
        painter.drawPath(line_path)

        offset_y = 1
        offset_x = 6

        line_path_2 = qg.QPainterPath()
        line_path_2.moveTo(offset_x, 50 - offset_y)
        line_path_2.lineTo((width - offset_x), 50 - offset_y)
        painter.setOpacity(0.85)

        painter.setPen(self._pen_line)
        painter.drawPath(line_path_2)

        painter.setBrush(self._brushClear)
        painter.end()
Example #13
0
    def paintEvent(self, event):
        painter = qg.QPainter(self)
        option = qg.QStyleOption()
        option.initFrom(self)

        x = option.rect.x()
        y = option.rect.y()
        height = option.rect.height()
        width = option.rect.width()

        painter.setRenderHint(qg.QPainter.Antialiasing)
        #gradient = QRadialGradient(qc.QPointF(width / 2, height / 2),float( width / 2 - 25))
        gradient = QRadialGradient(float(width / 2), float(height / 2),
                                   float(width / 2 + 5), float(width / 2),
                                   float(height / 2))
        #################################
        # draw TEXT
        #
        alignment = (qc.Qt.AlignHCenter | qc.Qt.AlignVCenter)
        text = self.text()
        font = self.font()

        text_width = self.fontMetrics.width(text)
        text_height = font.pointSize()

        textPath = qg.QPainterPath()
        textPath.addText(x, y, font, text)

        penHover = self._pen_textHover
        penText = self._pen_text
        penTick = self._pen_Ticktext

        self.setText(self.on_name)
        text = self.text()
        painter.fillRect(x, y, width, height, self._brushChecked)
        painter.setPen(self._pen_text_checked)
        painter.drawText(x, y, width, height, alignment, text)

        painter.setPen(self._pen_text_black)
        painter.drawText(x, y, width, height, alignment, text)

        if not self.isEnabled():
            #painter.fillRect(x,y,width,height, self._brushChecked)

            painter.fillRect(x, y, width, height, self._brushdisable)

        if self.isDown():
            gradient.setColorAt(0.0, self.col1)
            gradient.setColorAt(0.25, self.col2)
            gradient.setColorAt(0.5, self.col3)
            gradient.setColorAt(0.75, self.col4)
            gradient.setColorAt(1.0, self.col5)
            painter.fillRect(x, y, width, height, gradient)
            painter.setPen(self._pen_text_black)
            painter.drawText(x, y, width, height, alignment, text)

        elif self.underMouse():
            penTick.setCapStyle(qc.Qt.RoundCap)
            penHover.setCapStyle(qc.Qt.RoundCap)
            penTick.setStyle(qc.Qt.SolidLine)
            penHover.setStyle(qc.Qt.SolidLine)
            painter.fillRect(x, y, width, height, self.BRUSHHOVER)
            painter.setPen(penHover)
            painter.drawText(x, y, width, height, alignment, text)
            painter.setPen(penTick)
            painter.drawText(x, y, width, height, alignment, text)

        pixmap = qg.QPixmap(self.size())
        pixmap.fill(qc.Qt.transparent)
        painter = qg.QPainter(pixmap)
        painter.setBrush(qc.Qt.black)
        painter.drawRoundedRect(pixmap.rect(), 12, 12)
        painter.end()

        self.setMask(pixmap.mask())
Example #14
0
    def paintEvent(self, event):
        painter = qg.QPainter(self)
        option = qg.QStyleOption()
        option.initFrom(self)

        x = option.rect.x()
        y = option.rect.y()
        height = option.rect.height()
        width = option.rect.width()

        painter.setRenderHint(qg.QPainter.Antialiasing)
        #gradient = QRadialGradient(qc.QPointF(width / 2, height / 2),float( width / 2 - 25))
        gradient = QRadialGradient(float(width / 2), float(height / 2),
                                   float(width / 2 + 5), float(width / 2),
                                   float(height / 2))
        #################################
        # draw TEXT
        #
        alignment = (qc.Qt.AlignHCenter | qc.Qt.AlignVCenter)
        text = self.text()
        font = self.font()

        text_width = self.fontMetrics.width(text)
        text_height = font.pointSize()

        textPath = qg.QPainterPath()
        textPath.addText(x, y, font, text)

        penHover = self._pen_textHover
        penText = self._pen_text
        penTick = self._pen_Ticktext

        penText.setCapStyle(qc.Qt.RoundCap)
        penText.setStyle(qc.Qt.SolidLine)
        painter.fillRect(x, y, width, height, self._brushClear)
        painter.setPen(penText)
        painter.drawText(x, y, width, height, alignment, text)

        #painter.setBrush(self._brushClear)

        if self.isDown():
            gradient.setColorAt(0.0, self.col1)
            gradient.setColorAt(0.25, self.col2)
            gradient.setColorAt(0.5, self.col3)
            gradient.setColorAt(0.75, self.col4)
            gradient.setColorAt(1.0, self.col5)
            painter.fillRect(x, y, width, height, gradient)
            painter.setPen(self._pen_TickPressed)
            painter.drawText(x, y, width, height, alignment, text)

        elif self.underMouse():
            penTick.setCapStyle(qc.Qt.RoundCap)
            penHover.setCapStyle(qc.Qt.RoundCap)
            penTick.setStyle(qc.Qt.SolidLine)
            penHover.setStyle(qc.Qt.SolidLine)
            painter.fillRect(x, y, width, height, self.BRUSHHOVER)
            painter.setPen(penHover)
            painter.drawText(x, y, width, height, alignment, text)
            painter.setPen(penTick)
            painter.drawText(x, y, width, height, alignment, text)
Example #15
0
 def testSetQPointF(self):
     grad = QRadialGradient()
     grad.setCenter(QPointF(1, 2))
     self._compare(grad.center(), (1.0, 2.0))
Example #16
0
 def testQPointF(self):
     grad = QRadialGradient(QPointF(1, 2), 5, QPointF(3, 4))
     self._assertValues(grad)
Example #17
0
 def testSetQPointF(self):
     grad = QRadialGradient()
     grad.setCenter(QPointF(1, 2))
     self._compare(grad.center(), (1.0, 2.0))