コード例 #1
0
    def paintEvent(self, QPaintEvent):
        painter = QPainter()
        painter.begin(self)
        painter.setRenderHint(QPainter.Antialiasing)

        pen = QPen()
        pen.setWidth(self.__circle_width)

        painter.setPen(pen)
        width = 2 * self.__radius
        height = width
        q = QColor()
        q.setNamedColor("white")
        painter.setBrush(q)
        painter.drawEllipse(self.__circle_width, self.__circle_width, width,
                            height)

        if self.selected:
            color = QColor()
            color.setNamedColor("blue")
            pen.setColor(color)
            painter.setPen(pen)
            painter.setBrush(color)
            rect = QRect(0, 0, self.__size, self.__size)
            painter.drawText(rect, Qt.AlignCenter,
                             str(self.get_selection_number()))

        painter.end()
コード例 #2
0
ファイル: syntax_sql.py プロジェクト: ligm74/LiGM
def format_style(color, style=''):
    """Return a QTextCharFormat with the given attributes."""
    _color = QColor()
    _color.setNamedColor(color)

    _format = QTextCharFormat()
    _format.setForeground(_color)
    if 'bold' in style:
        _format.setFontWeight(QFont.Bold)
    if 'italic' in style:
        _format.setFontItalic(True)

    return _format
コード例 #3
0
    def paintEvent(self, QPaintEvent):
        pen_color = QColor()
        if self.selected:
            pen_color.setNamedColor("blue")
        else:
            pen_color.setNamedColor("black")

        pen = QPen()
        pen.setWidth(self.__pen_width)
        pen.setColor(pen_color)

        painter = QPainter()
        painter.begin(self)
        painter.setRenderHint(QPainter.Antialiasing)
        painter.setPen(pen)
        painter.drawPath(self.__branch)

        pen.setWidth(1)
        painter.setPen(pen)
        painter.setBrush(pen_color)  # Use same color as pen for brush

        painter.drawPath(self.__arrow)
        painter.end()