Ejemplo n.º 1
0
    def paint(self, painter, paintOptions, widget):
        myRect = self.boundingRect()

        painter.fillRect(self.__headerRect, self.__darkerColor)
        gradTop = self.__headerRect.bottomLeft()
        gradBot = gradTop + QtCore.QPointF(0, 4)
        gradient = QtGui.QLinearGradient(gradTop, gradBot)
        gradient.setColorAt(0, self.__shadowColor)
        gradient.setColorAt(1, self.__color)
        brush = QtGui.QBrush(gradient)

        bottomRect = myRect.adjusted(0, self.__headerRect.bottom(), 0, 0)
        painter.fillRect(bottomRect, brush)

        if not safeEffects:
            oldPen = painter.pen()
            pen = QtGui.QPen()
            pen.setColor(QtGui.QColor(10, 10, 10, 100))
            pen.setWidth(1)
            painter.setPen(pen)
            painter.drawRect(myRect.adjusted(0.5, 0.5, -0.5, -0.5))
            painter.setPen(oldPen)

        painter.setBrush(QtGui.QBrush(self.__darkerColor))
        painter.drawConvexPolygon(self.__handlePoly)
Ejemplo n.º 2
0
    def color_line(self):
        """ Color the current line """

        cursor = self.textCursor()
        cursor.movePosition(QtGui.QTextCursor.StartOfLine)

        newpos = cursor.position()
        pos = -1

        while(newpos != pos):
            cursor.movePosition(QtGui.QTextCursor.NextWord)

            pos = newpos
            newpos = cursor.position()

            cursor.select(QtGui.QTextCursor.WordUnderCursor)
            word = str(cursor.selectedText ().toAscii())

            if(not word) : continue

            (R, G, B) = self.colorizer.get_color(word)

            format = cursor.charFormat()
            format.setForeground(QtGui.QBrush(QtGui.QColor(R, G, B)))
            cursor.setCharFormat(format)
Ejemplo n.º 3
0
 def __init__(self, parent, *args, **kwargs):
     QtGui.QGraphicsEllipseItem.__init__(self, 0, 0 , self.size, self.size, None)
     Connector.__init__(self, *args, **kwargs)
     self.setBrush(QtGui.QBrush(QtCore.Qt.darkGreen))
     # Needs to be visible or else won't receive events
     # we override paint in order to hide the item
     self.setVisible(True)
     self.fakeParent = parent
Ejemplo n.º 4
0
 def _get_brush(self, color):
     """ Returns a brush for the color.
     """
     result = self._brushes.get(color)
     if result is None:
         qcolor = self._get_color(color)
         result = QtGui.QBrush(qcolor)
         self._brushes[color] = result
     return result
Ejemplo n.º 5
0
 def __init__(self, parent=None):
     AleaQGraphicsFontButton.__init__(self, parent)
     self.fontColorChanged = AleaSignal(QtGui.QFont)
     # gradient = QtGui.QConicalGradient()
     # gradient.setCenter(self.boundingRect().center())
     # for hue, pos in zip(AleaQGraphicsColorWheel._stopHues, AleaQGraphicsColorWheel._stopPos):
     #     gradient.setColorAt(pos, QtGui.QColor.fromHsv(hue, 255, 255, 255))
     # self.setBrush(QtGui.QBrush(gradient))
     self.setBrush(QtGui.QBrush(QtGui.QColor(255, 0, 0)))
Ejemplo n.º 6
0
 def __init__(self, radius=3.0, parent=None):
     QtGui.QGraphicsEllipseItem.__init__(self, 0, 0, radius * 2, radius * 2,
                                         parent)
     AleaQGraphicsVanishingMixin.__init__(self)
     AleaQGraphicsButtonMixin.__init__(self)
     self.colorChanged = AleaSignal(QtGui.QColor)
     gradient = QtGui.QConicalGradient()
     gradient.setCenter(radius, radius)
     for hue, pos in zip(self._stopHues, self._stopPos):
         gradient.setColorAt(pos, QtGui.QColor.fromHsv(hue, 255, 255, 255))
     self.setBrush(QtGui.QBrush(gradient))
Ejemplo n.º 7
0
        def paintEvent(self, event):
            if self._edit_mode is False:
                return
            painter = QtGui.QPainter(self)
            painter.setRenderHint(QtGui.QPainter.Antialiasing)

            pen = painter.pen()
            if self._hovered:
                brush = QtGui.QBrush(QtGui.QColor(120, 190, 255, 200))
                pen.setColor(QtGui.QColor(255, 255, 255, 255))
            else:
                brush = QtGui.QBrush(QtGui.QColor(120, 190, 255, 70))
                pen.setColor(QtGui.QColor(0, 0, 0, 127))

            painter.setBrush(brush)
            painter.setPen(pen)

            adj = painter.pen().width()
            rect = self.contentsRect().adjusted(adj, adj, -adj, -adj)
            if self._bottom:
                painter.drawConvexPolygon(QtGui.QPolygon([rect.bottomRight(), rect.bottomLeft(), rect.topLeft()]))
            else:
                painter.drawConvexPolygon(QtGui.QPolygon([rect.topRight(), rect.bottomRight(), rect.topLeft()]))
Ejemplo n.º 8
0
    def __init__(self, vertex, graph, parent=None):
        QtGui.QGraphicsEllipseItem.__init__(self, 0.0, 0.0,
                                            self.__vertex_size__.width(),
                                            self.__vertex_size__.height(),
                                            parent)
        Vertex.__init__(self, vertex, graph)
        self.setZValue(1.0)

        #we choose the avocado colors
        self.setBrush(QtGui.QBrush(QtCore.Qt.yellow))
        pen = QtGui.QPen(QtCore.Qt.darkGreen)
        pen.setWidth(self.__border_size__ - 2)
        self.setPen(pen)

        self.initialise_from_model()
Ejemplo n.º 9
0
    def __init__(self, node, parent, parameter_str, interface):
        """Constructor

        :Parameters:
         - `node` (Node) - node that own the widget
         - `parent` (QWidget) - parent widget
         - `parameter_str` (str) - the parameter key the widget is associated to
         - `interface` (Ismth) - instance of interface object
        """
        QtGui.QPushButton.__init__(self, parent)
        IInterfaceWidget.__init__(self, node, parent, parameter_str, interface)
        self.setMinimumSize(64, 64)

        self._color = (0, 0, 0)
        self._brush = QtGui.QBrush(QtGui.QColor(*self._color[:3]))

        QtCore.QObject.connect(self, QtCore.SIGNAL("clicked(bool)"),
                               self.open_color_dialog)

        self.notify(node, ("input_modified", self.param_str))
Ejemplo n.º 10
0
    def write(self, text):
        """
        Simulate stdin, stdout, and stderr.
        """
        # The output of self.append(text) contains to many newline characters,
        # so work around QtGui.QTextEdit's policy for handling newline characters.

        cursor = self.textCursor()

        cursor.movePosition(QtGui.QTextCursor.End)

        pos1 = cursor.position()
        cursor.insertText(text)

        self.cursor_pos = cursor.position()
        self.setTextCursor(cursor)
        self.ensureCursorVisible ()

        # Set the format
        cursor.setPosition(pos1, QtGui.QTextCursor.KeepAnchor)
        format = cursor.charFormat()
        format.setForeground(QtGui.QBrush(QtGui.QColor(0, 0, 0)))
        cursor.setCharFormat(format)
Ejemplo n.º 11
0
 def set_color(self, color):
     self._color = color
     self._brush = QtGui.QBrush(QtGui.QColor(*self._color[:3]))