def test_opacity_widget(qtapi, opacity_widget):
    from pyvmmonitor_qt.qt.QtGui import QColor
    assert opacity_widget.model is not None
    color = opacity_widget.model.color = QColor.fromRgb(100, 90, 80)
    assert opacity_widget.model.opacity == 255
    opacity_widget.model.opacity = 150
    assert opacity_widget._widget_0._slider.value == 150
Ejemplo n.º 2
0
    def __init__(self, parent):
        super(PythonHighlighter, self).__init__(parent)
        self.rules = []

        brush = QBrush(QtCore.Qt.darkGreen, QtCore.Qt.SolidPattern)
        builtin = QTextCharFormat()
        builtin.setForeground(brush)
        builtin.setFontWeight(QFont.Bold)
        builtins = dir(__builtin__)

        for word in builtins:
            pattern = QtCore.QRegExp("\\b{w}\\b".format(w=word))
            rule = HighlightRule(pattern, builtin)
            self.rules.append(rule)

        brush = QBrush(QtCore.Qt.darkBlue, QtCore.Qt.SolidPattern)
        keyword = QTextCharFormat()
        keyword.setForeground(brush)
        keyword.setFontWeight(QFont.Bold)
        keywords = pythonkeyword.kwlist

        for word in keywords:
            pattern = QtCore.QRegExp("\\b{w}\\b".format(w=word))
            rule = HighlightRule(pattern, keyword)
            self.rules.append(rule)

        brush = QBrush(QColor.fromRgb(255, 140, 0), QtCore.Qt.SolidPattern)
        pattern = QtCore.QRegExp("#[^\n]*")
        comment = QTextCharFormat()
        comment.setForeground(brush)
        comment.setFontWeight(QFont.Light)
        rule = HighlightRule(pattern, comment)
        self.rules.append(rule)

        self.setDocument(parent.document())
def test_opacity_widget(qtapi, opacity_widget):
    from pyvmmonitor_qt.qt.QtGui import QColor
    assert opacity_widget.model is not None
    color = opacity_widget.model.color = QColor.fromRgb(100, 90, 80)
    assert opacity_widget.model.opacity == 255
    opacity_widget.model.opacity = 150
    assert opacity_widget._widget_0._slider.value == 150
Ejemplo n.º 4
0
    def lineNumberAreaPaintEvent(self, event):
        painter = QPainter(self._lineNumber)
        painter.fillRect(event.rect(), QColor.fromRgb(200, 200, 200))
        block = self.firstVisibleBlock()
        blockNumber = block.blockNumber()
        top = int(
            self.blockBoundingGeometry(block).translated(
                self.contentOffset()).top())
        bottom = top + int(self.blockBoundingRect(block).height())

        while block.isValid() and top <= event.rect().bottom():
            if block.isVisible() and bottom >= event.rect().top():
                number = str(blockNumber + 1)
                painter.setPen(QtCore.Qt.black)
                painter.drawText(0, top, self._lineNumber.width(),
                                 self.fontMetrics().height(),
                                 QtCore.Qt.AlignRight, number)

            block = block.next()
            top = bottom
            bottom = top + int(self.blockBoundingRect(block).height())
            blockNumber += 1