Пример #1
0
 def setNodeState(self, running_nodes, stopped_nodes, error_nodes):
     '''
     Sets the state of this capability.
     :param running_nodes: a list with running nodes.
     :type running_nodes: [str]
     :param stopped_nodes: a list with not running nodes.
     :type stopped_nodes: [str]
     :param error_nodes: a list with nodes having a problem.
     :type error_nodes: [str]
     '''
     self.setAutoFillBackground(True)
     self.setBackgroundRole(QPalette.Base)
     palette = QPalette()
     if error_nodes:
         brush = QBrush(QColor(255, 100, 0))
     elif running_nodes and stopped_nodes:
         brush = QBrush(QColor(140, 185, 255))  # 30, 50, 255
     elif running_nodes:
         self.on_button.setFlat(True)
         self.off_button.setFlat(False)
         brush = QBrush(QColor(59, 223, 18))  # 59, 223, 18
     else:
         brush = QBrush(QColor(255, 255, 255))
         self.on_button.setFlat(False)
         self.off_button.setFlat(True)
     palette.setBrush(QPalette.Active, QPalette.Base, brush)
     brush.setStyle(Qt.SolidPattern)
     palette.setBrush(QPalette.Inactive, QPalette.Base, brush)
     self.setPalette(palette)
 def setNodeState(self, running_nodes, stopped_nodes, error_nodes):
     '''
     Sets the state of this capability.
     @param running_nodes: a list with running nodes.
     @type running_nodes: C{[str]}
     @param stopped_nodes: a list with not running nodes.
     @type stopped_nodes: C{[str]}
     @param error_nodes: a list with nodes having a problem.
     @type error_nodes: C{[str]}
     '''
     self.setAutoFillBackground(True)
     self.setBackgroundRole(QPalette.Base)
     palette = QPalette()
     if error_nodes:
         brush = QBrush(QColor(255, 100, 0))
     elif running_nodes and stopped_nodes:
         brush = QBrush(QColor(140, 185, 255))  # 30, 50, 255
     elif running_nodes:
         self.on_button.setFlat(True)
         self.off_button.setFlat(False)
         brush = QBrush(QColor(59, 223, 18))  # 59, 223, 18
     else:
         brush = QBrush(QColor(255, 255, 255))
         self.on_button.setFlat(False)
         self.off_button.setFlat(True)
     palette.setBrush(QPalette.Active, QPalette.Base, brush)
     brush.setStyle(Qt.SolidPattern)
     palette.setBrush(QPalette.Inactive, QPalette.Base, brush)
     self.setPalette(palette)
Пример #3
0
 def paint(self, painter, option, widget):
     """Overwrites BlockItem.paint so that we can fill in the block rectangles"""
     brush = QBrush()
     brush.setStyle(Qt.SolidPattern)
     brush.setColor(self.bgcolor)
     painter.fillRect(self.rect(), brush)
     border_pen = QPen()
     border_pen.setBrush(self.border_color)
     border_pen.setStyle(Qt.SolidLine)
     border_pen.setWidth(self.border_width)
     painter.setPen(border_pen)
     painter.drawRect(self.rect())
Пример #4
0
    def paint(self, painter, option, widget):
        # Paint background
        brush = QBrush()
        brush.setStyle(Qt.SolidPattern)
        brush.setColor(self.bgcolor)
        painter.fillRect(self.rect(), brush)
        # Paint border
        border_pen = QPen()
        border_pen.setBrush(self.border_color)
        border_pen.setStyle(Qt.SolidLine)
        border_pen.setWidth(self.border_width)
        painter.setPen(border_pen)
        painter.drawRect(self.rect())
        rect = self.geometry()
        # Create arrows
        arrow_scale = 0.25
        arrow_width = rect.width() * arrow_scale
        arrow_height = arrow_width * 0.8
        arrow_margin = (rect.width() - arrow_width) / 2.0

        brush.setColor(self.label_color)
        painter.setPen(Qt.NoPen)
        painter.setBrush(brush)
        arrow = None

        if self.topBand == self.dest_band_item:
            # Draw pointing up
            arrow = QPolygon([QPoint(0, arrow_height), QPoint(arrow_width, arrow_height), QPoint(arrow_width / 2.0, 0)])
            arrow.translate(self.rect().x() + arrow_margin, self.rect().y() + 1)
        else:
            # Draw pointing down
            arrow = QPolygon([QPoint(0, 0), QPoint(arrow_width, 0), QPoint(arrow_width / 2.0, arrow_height)])
            arrow.translate(self.rect().x() + arrow_margin, self.rect().y() + rect.height() - arrow_height)
        painter.drawPolygon(arrow)

        # Label
        painter.setPen(self.label_color)
        painter.rotate(-90)
        fm = painter.fontMetrics()
        elided = fm.elidedText(self.label, Qt.ElideRight, rect.height())
        twidth = fm.width(elided)
        painter.drawText(-twidth - (rect.height() - twidth) / 2, rect.width() - 2, elided)
Пример #5
0
    def paint(self, painter, option, widget):
        # Paint background
        brush = QBrush()
        brush.setStyle(Qt.SolidPattern)
        brush.setColor(self.bgcolor)
        painter.fillRect(self.rect(), brush)
        # Paint border
        border_pen = QPen()
        border_pen.setBrush(self.border_color)
        border_pen.setStyle(Qt.SolidLine)
        border_pen.setWidth(self.border_width)
        painter.setPen(border_pen)
        painter.drawRect(self.rect())
        rect = self.geometry()
        # Create arrows
        arrow_scale = 0.25
        arrow_width = rect.width() * arrow_scale
        arrow_height = arrow_width * 0.8
        arrow_margin = (rect.width() - arrow_width) / 2.0

        brush.setColor(self.label_color)
        painter.setPen(Qt.NoPen)
        painter.setBrush(brush)
Пример #6
0
 def paint(self, painter, option, widget):
     brush = QBrush()
     brush.setStyle(Qt.SolidPattern)
     brush.setColor(QColor("red"))
     painter.fillRect(self.rect(), brush)