コード例 #1
0
def glass_path(scene, x, y, w, h, colr):

    qp = QPainterPath()
    qp.addRoundedRect(x, y, w, h, 5, 5)

    gradient = QLinearGradient(0, +0, 0, 1)
    gradient.setCoordinateMode(QGradient.ObjectBoundingMode)
    gradient.setColorAt(0, colr)
    gradient.setColorAt(1, colr.lighter(150))
    brush = QBrush(gradient)

    item = QGraphicsPathItem()
    item.setPath(qp)
    item.setBrush(brush)
    scene.addItem(item)

    # Draw glass reflection

    glass = QPainterPath()
    r = 3
    glass.addRoundedRect(x + r, y + r, w - 2 * r, 2 * r, r, r)

    gradient = QLinearGradient(0, +0, 0, 1)
    gradient.setCoordinateMode(QGradient.ObjectBoundingMode)
    gradient.setColorAt(0, QColor(255, 255, 255, 188))
    gradient.setColorAt(1, QColor(255, 255, 255, 0))
    brush = QBrush(gradient)

    item = QGraphicsPathItem()
    item.setPath(glass)
    item.setBrush(brush)
    item.setPen(QPen(Qt.transparent))
    scene.addItem(item)
コード例 #2
0
ファイル: stream.py プロジェクト: nisseblink/livestreamer-ui
    def is_online_callback(self):

        outputBytes = self.process.readAll().data()

        outputUnicode = outputBytes.decode('utf-8')

        try:
            outputObject = json.loads(outputUnicode)

        except ValueError as errorMessage:
            print(errorMessage)
            return

        brush = QBrush(Qt.SolidPattern)
        if outputObject.get('error'):
            color = QColor(255, 0, 0)  #red
            onlineStatus = 'Off'
        else:
            color = QColor(0, 255, 0)  #green
            onlineStatus = 'On'
        brush.setColor(color)

        itemWidget = self.table_widget_item

        itemWidget.setBackground(brush)
        itemWidget.setText(onlineStatus)
コード例 #3
0
ファイル: material.py プロジェクト: xuyi2008yi/material
 def paintEvent(self, event):
     painter = QPainter()
     painter.begin(self)
     painter.setRenderHint(QPainter.HighQualityAntialiasing)
     painter.setRenderHint(QPainter.Antialiasing)
     painter.setRenderHint(QPainter.SmoothPixmapTransform)
     # change the look for on/off
     if self.isChecked():
         # blue fill
         brush = QBrush(self.color1)
         painter.setBrush(brush)
         painter.drawRoundedRect(0, 7,
                                 self.width() - 2,
                                 self.height() - 15,
                                 self.height() / 2 - 10,
                                 self.height() / 2)
         brush = QBrush(self.lighter(self.color1))
         painter.setBrush(brush)
         painter.drawEllipse(self.width() - self.height(), 0, self.height(),
                             self.height())
     else:
         # gray fill
         brush = QBrush(self.color2)
         painter.setBrush(brush)
         painter.drawRoundedRect(1, 7,
                                 self.width() - 3,
                                 self.height() - 15,
                                 self.height() / 2 - 10,
                                 self.height() / 2)
         brush = QBrush(QColor(100, 100, 100))
         painter.setBrush(brush)
         painter.drawEllipse(0, 0, self.height(), self.height())
     painter.end()
コード例 #4
0
    def __init__(self, s, parent=None):
        """
        Default class constructor.

        :param `s`: TOWRITE
        :type `s`: QRubberBand.Shape
        :param `parent`: Pointer to a parent widget instance.
        :type `parent`: `QWidget`_
        """
        super(SelectBox, self).__init__(s, parent)

        # private
        self._leftBrushColor = QColor()
        self._rightBrushColor = QColor()
        self._leftPenColor = QColor()
        self._rightPenColor = QColor()
        self._alpha = 255  # quint8  #: TODO: what is the initial int?

        self._dirBrush = QBrush()
        self._leftBrush = QBrush()
        self._rightBrush = QBrush()

        self._dirPen = QPen()
        self._leftPen = QPen()
        self._rightPen = QPen()

        self._boxDir = False  #: TODO: is this initial bool value right?

        # Default values
        self.setColors(QColor(Qt.darkGreen), QColor(Qt.green), QColor(Qt.darkBlue), QColor(Qt.blue), 32)
コード例 #5
0
    def __init__(self, s, parent=None):
        """
        Default class constructor.

        :param `s`: TOWRITE
        :type `s`: QRubberBand.Shape
        :param `parent`: Pointer to a parent widget instance.
        :type `parent`: `QWidget`_
        """
        super(SelectBox, self).__init__(parent)

        # private
        self._leftBrushColor = QColor()
        self._rightBrushColor = QColor()
        self._leftPenColor = QColor()
        self._rightPenColor = QColor()
        self._alpha = 255  # quint8  #: TODO: what is the initial int?

        self._dirBrush = QBrush()
        self._leftBrush = QBrush()
        self._rightBrush = QBrush()

        self._dirPen = QPen()
        self._leftPen = QPen()
        self._rightPen = QPen()

        self._boxDir = False  #: TODO: is this initial bool value right?

        # Default values
        self.setColors(QColor(Qt.darkGreen), QColor(Qt.green),
                       QColor(Qt.darkBlue), QColor(Qt.blue), 32)
コード例 #6
0
    def hoverEnterEvent(self, event):
        super(HooverBar, self).hoverEnterEvent(event)

        if self.gi == None:
            self.gi = QGraphicsRectItem(0, 0, 100, 100)
            self.gi.setBrush(QBrush(QColor(0, 64, 0, 192)))
            self.gi.setPen(QPen(Qt.transparent))
            self.gi.setPos(event.scenePos().x() + 20,
                           event.scenePos().y() + 20)

            x = y = 10
            w = 0
            for t in self.description:
                description = QGraphicsSimpleTextItem()
                description.setFont(self.base_font)
                description.setBrush(QBrush(Qt.white))
                description.setText(t)
                description.setParentItem(self.gi)
                description.setPos(x, y)
                y += description.boundingRect().height()
                w = max(w, description.boundingRect().width())
            y += x
            w += 2 * x

            self.gi.setRect(0, 0, w, y)
            self.scene().addItem(self.gi)
コード例 #7
0
class GraphTreeItemDelegate(QtGui.QStyledItemDelegate):
	_textBrush      = QBrush( QColor( '#dd5200' ) )
	_textPen        = QPen( QColor( '#dddddd' ) )
	_textPenGroup   = QPen( QColor( '#ada993' ) )
	_backgroundBrushHovered  = QBrush( QColor( '#454768' ) )
	_backgroundBrushSelected = QBrush( QColor( '#515c84' ) )
	
	def paint(self, painter, option, index):
		painter.save()
		index0 = index.sibling( index.row(), 0 )
		utype = index0.data( Qt.UserRole )

		# # set background color
		if option.state & QStyle.State_Selected:
			painter.setPen  ( Qt.NoPen )
			painter.setBrush( GraphTreeItemDelegate._backgroundBrushSelected )
			painter.drawRect(option.rect)
		elif option.state & QStyle.State_MouseOver:
			painter.setPen  ( Qt.NoPen )
			painter.setBrush( GraphTreeItemDelegate._backgroundBrushHovered )
			painter.drawRect(option.rect)

		rect = option.rect
		icon = QIcon( index.data( Qt.DecorationRole) )
		rect.adjust( 5, 0, 0, 0 )
		if icon and not icon.isNull():
			icon.paint( painter, rect, Qt.AlignLeft )
			rect.adjust( 22, 0, 0, 0 )
		text = index.data(Qt.DisplayRole)
		if utype == 1: #GROUP
			painter.setPen( GraphTreeItemDelegate._textPenGroup )
		else:
			painter.setPen( GraphTreeItemDelegate._textPen )
		painter.drawText( rect, Qt.AlignLeft | Qt.AlignVCenter, text )
		painter.restore()
コード例 #8
0
ファイル: Polygon.py プロジェクト: Ingener74/White-Albatross
    def draw(self, painter, scale):

        painter.save()
        painter.setPen(QPen(QBrush(QColor(232, 109, 21) if self.state is self.add_point else
                                   QColor(21, 144, 232)),
                            self.lineWidth(scale),
                            Qt.SolidLine))
        painter.drawPolygon(QPolygon(self.polygon))

        for i, poly in enumerate(self.convex_polygons):
            if poly:
                painter.setPen(QPen(QBrush(Figure.COLORS[i % len(Figure.COLORS)]),
                                    self.lineWidth(scale),
                                    Qt.SolidLine))
                color = Figure.COLORS[i % len(Figure.COLORS)]
                color.setAlpha(150)
                painter.setBrush(QBrush(QColor(color)))
                painter.drawPolygon(QPolygon(poly))

        for point in self.polygon:
            self.drawControlPoint(painter, point,
                                  QColor(31, 174, 222) if point is self.polygon[0] else
                                  QColor(222, 79, 31) if point is self.polygon[-1] else
                                  QColor(78, 222, 31), scale)

        Figure.draw(self, painter, scale)
        painter.restore()
コード例 #9
0
ファイル: stream.py プロジェクト: nisseblink/livestreamer-ui
    def is_online_callback(self):

        outputBytes = self.process.readAll().data()

        outputUnicode = outputBytes.decode("utf-8")

        try:
            outputObject = json.loads(outputUnicode)

        except ValueError as errorMessage:
            print(errorMessage)
            return

        brush = QBrush(Qt.SolidPattern)
        if outputObject.get("error"):
            color = QColor(255, 0, 0)  # red
            onlineStatus = "Off"
        else:
            color = QColor(0, 255, 0)  # green
            onlineStatus = "On"
        brush.setColor(color)

        itemWidget = self.table_widget_item

        itemWidget.setBackground(brush)
        itemWidget.setText(onlineStatus)
コード例 #10
0
ファイル: qbrush_test.py プロジェクト: Hasimir/PySide
    def testQColor(self):
        #QBrush(QColor) constructor
        color = QColor('black')
        obj = QBrush(color)
        self.assertEqual(obj.color(), color)

        obj = QBrush(Qt.blue)
        self.assertEqual(obj.color(), Qt.blue)
コード例 #11
0
    def __init__(self, parent=None, conditional=False):
        if conditional:
            self.pen = QPen(CONDITIONAL_TRANSITION_COLOR)
            self.brush = QBrush(CONDITIONAL_TRANSITION_COLOR)
        else:
            self.pen = QPen(NON_CONDITIONAL_TRANSITION_COLOR)
            self.brush = QBrush(NON_CONDITIONAL_TRANSITION_COLOR)

        self.pen.setWidth(4)
        QWidget.__init__(self, parent)
コード例 #12
0
 def recolor_cells(self, min_val, max_val):
     cmap = ColorMapper(max_val, min_val)
     the_items = self.get_all_table_items()
     for the_item in the_items:
         the_qtype = the_item.type()
         if the_qtype > QSTRING:
             data_item = (self.inv_qtype(the_qtype)(the_item.text()))
             the_color = cmap.rgb_color_from_val(data_item)
             newBrush = QBrush()
             newBrush.setColor(QColor(the_color[0], the_color[1], the_color[2]))
             newBrush.setStyle(QtCore.Qt.SolidPattern)
             the_item.setBackground(newBrush)
コード例 #13
0
ファイル: PostView.py プロジェクト: wiz21b/koi
    def hoverEnterEvent(self, event):  # QGraphicsSceneHoverEvent * event )
        # BUG I had a crash running this, I suspect ownership issues regarding
        # graphics items...

        global configuration
        #mainlog.debug("hoverEnterEvent pos={}-{}".format(event.scenePos().x(),event.scenePos().y()))
        # mainlog.debug("hoverEnterEvent data={}".format(self.data))
        super(HooverBar, self).hoverEnterEvent(event)

        if self.gi == None:
            if self.hoover_text:
                self.gi = QGraphicsRectItem(0, 0, 100, 100)
                self.gi.setBrush(QBrush(QColor(0, 64, 0, 192)))
                self.gi.setPen(QPen(Qt.transparent))
                self.gi.setPos(event.scenePos().x() + 20,
                               event.scenePos().y() + 20)

                # txt = [ "" ]

                # txt = [ u"{} {}".format(self.data.production_file.order_part.human_identifier,
                #                        date_to_dmy(self.data.production_file.order_part.deadline)),
                #         nstr(self.data.production_file.order_part.description),
                #         nstr(self.data.description),
                #         _("{}x{}={}h, rest:{}h").format(self.data.production_file.order_part.qty,
                #                                         nice_round(self.data.planned_hours),
                #                                         nice_round(self.data.production_file.order_part.qty*self.data.planned_hours),
                #                                         nice_round(self.data.planned_hours*self.data.production_file.order_part.qty - self.data.done_hours))]

                x = y = 10
                w = 0
                for t in self.hoover_text:
                    description = QGraphicsSimpleTextItem()
                    description.setFont(self.base_font)
                    description.setBrush(QBrush(Qt.white))
                    description.setText(t)
                    description.setParentItem(self.gi)
                    description.setPos(x, y)
                    y += description.boundingRect().height()
                    w = max(w, description.boundingRect().width())
                y += x
                w += 2 * x

                # description.setHtml(u"|{}| <b>{}</b><br/>{}<br>{}x{}={}h".format(
                #         self.data.production_file.order_part.human_identifier,
                #         self.data.production_file.order_part.description,
                #         self.data.description,
                #         self.data.production_file.order_part.qty, self.data.planned_hours, self.data.production_file.order_part.qty*self.data.planned_hours))

                # description.setDefaultTextColor(Qt.white)
                # br = description.boundingRect()

                self.gi.setRect(0, 0, w, y)
                self.scene().addItem(self.gi)
コード例 #14
0
    def __init__(self, data_list, header_rows=0, roundit=None, cmap=None, click_handler=None, resize_columns=True, stretch_last=False, header_text=None, row_height=0, sort_column=0, sort_order=QtCore.Qt.AscendingOrder):
        self._data_list = data_list
        self._nrows = len(self._data_list)
        self._ncols = len(self._data_list[0])
        QTableWidget.__init__(self, self._nrows, self._ncols)
        self.setWordWrap(True) # I think it is already true by default
        if header_rows > 0:
            self.setHorizontalHeaderLabels(self._data_list[0])
            self._data_list = self._data_list[1:]
            self._nrows -= 1

        for r in range(self._nrows):
            for c in range(self._ncols):
                data_item = self._data_list[r][c]
                qtype = self.get_qtype(data_item)
                if (roundit != None) and (qtype == QFLOAT):  # @UndefinedVariable
                    data_item = round(data_item, roundit)
                if (r < header_rows - 1):
                    data_item = "_" + str(data_item) # do this so the header rows are sorted to the top
                # newItem = QTableWidgetItem(str(data_item))
                newItem = QTableWidgetItem(type=qtype)
                if type(data_item) == str:
                    newItem.setText(data_item)
                else:
                    newItem.setData(QtCore.Qt.DisplayRole, data_item)
                if r < header_rows - 1:
                    newItem.setFont(QFont("Helvetica", 12, QFont.Bold))
                else:
                    newItem.setFont(QFont("Helvetica", 12))
                    if (cmap != None) and (type(data_item) == float) and (r >= header_rows):
                        the_color = cmap.rgb_color_from_val(data_item)
                        newBrush = QBrush()
                        newBrush.setColor(QColor(the_color[0], the_color[1], the_color[2]))
                        newBrush.setStyle(QtCore.Qt.SolidPattern)
                        newItem.setBackground(newBrush)
                self.setItem(r, c, newItem)
        if resize_columns:
            self.resizeColumnsToContents()
        self.resizeRowsToContents()
        self.sortItems(0, order=QtCore.Qt.AscendingOrder)
        self.setSortingEnabled(True)
        if row_height != 0:
            vh = self.verticalHeader()
            vh.setDefaultSectionSize(row_height)
        if click_handler != None:
            self._click_handler = click_handler
            self.itemClicked.connect(self.item_click_action)
        if stretch_last:
            hh = self.horizontalHeader()
            hh.setStretchLastSection(True)
        self.roundit = roundit
        self.header_rows = header_rows
コード例 #15
0
ファイル: syntaxhlighter.py プロジェクト: uchuugaka/editor
    def formatConverterFunction(format):
        if format == qutepart.syntax.TextFormat():
            return None  # Do not apply default format. Performance optimization

        qtFormat = QTextCharFormat()
        qtFormat.setForeground(QBrush(QColor(format.color)))
        qtFormat.setBackground(QBrush(QColor(format.background)))
        qtFormat.setFontItalic(format.italic)
        qtFormat.setFontWeight(QFont.Bold if format.bold else QFont.Normal)
        qtFormat.setFontUnderline(format.underline)
        qtFormat.setFontStrikeOut(format.strikeOut)

        return qtFormat
コード例 #16
0
 def recolorold(self):
     cmap = ColorMapper(self.max_val.value, self.min_val.value)
     for r in range(self._nrows):
         for c in range(self._ncols):
             data_item = self._data_list[r][c]
             qtype = self.get_qtype(data_item)
             if (self.roundit != None) and (qtype == QFLOAT):  # @UndefinedVariable
                 data_item = round(data_item, self.roundit)
             # newItem = QTableWidgetItem(str(data_item))
             if (qtype > QSTRING) and (r >= self.header_rows - 1):
                 the_color = cmap.rgb_color_from_val(data_item)
                 newBrush = QBrush()
                 newBrush.setColor(QColor(the_color[0], the_color[1], the_color[2]))
                 newBrush.setStyle(QtCore.Qt.SolidPattern)
                 self.tableWidget.item(r, c).setBackground(newBrush)
コード例 #17
0
ファイル: lines_chart.py プロジェクト: wiz21b/koi
    def _draw_horizontal_ruler(self, painter, text, y_value, color):

        y = y_value * self.y_factor

        pen = QPen()
        pen.setCapStyle(Qt.SquareCap)
        pen.setColor(color)

        qp = QPainterPath()

        r = QRect(1,1,1000,1000)
        bb = painter.boundingRect(r,Qt.AlignLeft,text)
        bb = QRect(self.x_base,self.y_base - y - bb.height(), bb.width() + 2, bb.height())

        # print("{} {} {} {}".format(bb.x(),bb.y(),bb.width(),bb.height()))

        fill_color = QColor(0,0,0)
        fill_color.setAlpha(128)
        brush = QBrush(fill_color)

        painter.fillRect(bb,brush)

        qp.moveTo(self.x_base,self.y_base - y)
        qp.lineTo(self.total_width + self.x_base, self.y_base - y)

        painter.setPen(pen)
        painter.drawPath(qp)

        text_pen = QPen()
        text_pen.setCapStyle(Qt.RoundCap)
        text_pen.setColor(color) # alpha=255=fully opaque
        text_pen.setWidth(1)

        painter.setPen(text_pen)
        painter.drawText(self.x_base,self.y_base - y - 5,text)
コード例 #18
0
    def _draw_edges(self, painter, topleft_point, bottomright_point):

        for edge in self._edges:
            edge_coords = edge.coordinates

            color = QColor(0x70, 0x70, 0x70)
            pen = QPen(color)
            pen.setWidth(1.5)
            painter.setPen(pen)

            for from_, to_ in zip(edge_coords, edge_coords[1:]):
                start_point = QPointF(*from_)
                end_point = QPointF(*to_)
                # optimization: don't draw edges that are outside of the current scope
                if (start_point.x() > bottomright_point.x() or start_point.y() > bottomright_point.y()) and \
                        (end_point.x() > bottomright_point.x() or end_point.y() > bottomright_point.y()):
                    continue
                elif (start_point.x() < topleft_point.x() or start_point.y() < topleft_point.y()) and \
                        (end_point.x() < topleft_point.x() or end_point.y() < topleft_point.y()):
                    continue
                painter.drawPolyline((start_point, end_point))

            # arrow
            # end_point = self.mapToScene(*edges[-1])
            end_point = (edge_coords[-1][0], edge_coords[-1][1])
            arrow = [
                QPointF(end_point[0] - 3, end_point[1]),
                QPointF(end_point[0] + 3, end_point[1]),
                QPointF(end_point[0], end_point[1] + 6)
            ]
            brush = QBrush(color)
            painter.setBrush(brush)
            painter.drawPolygon(arrow)
コード例 #19
0
ファイル: snippet.py プロジェクト: szabo92/gistable
    def update(self):
        self.setWindowTitle(time.ctime(time.time()))
        row = 0
        for (user, _, _, _) in VIDEO:
            #             index=0
            for index, info in enumerate(result):
                if user == info[0]:
                    self.insertRow(row)
                    for column in range(4):
                        item = QTableWidgetItem(info[column])
                        if info[4]:
                            item.setForeground(QBrush(QColor(255, 0, 0)))
                        self.setItem(row, column, item)
                    result.pop(index)
                    break
#                 index+=1
            row += 1

#         for info in result:
#             self.insertRow(row)
#             for column in range(4):
#                 item = QTableWidgetItem(info[column])
#                 if info[4]:
#                     item.setForeground(QBrush(QColor(255,0,0)))
#                 self.setItem(row, column, item)
#             row +=1
        self.resizeColumnsToContents()
        self.setFixedSize(self.horizontalHeader().length() + 30,
                          self.verticalHeader().length() + 30)
        self.show()
コード例 #20
0
 def __addData(
     self
 ):  #oddly in the vertical mode some data entries seem to be missing
     for col in xrange(len(self.dataTableColumnData)):
         dataList = self.dataTableColumnData[col]
         for row in xrange(len(dataList)):
             try:
                 value = dataList[
                     row]  # don't touch "values"; they could be pre-formatted strings
                 newItem = SortedTableWidgetItem()  # use custom item class
                 newItem.setData(Qt.DisplayRole, value)
                 newItem.setTextAlignment(Qt.AlignRight)
                 newItem.setFont(QFont("Fixed"))
                 if self.isColored:
                     if not (self._mode == MODE_SUBCONDITIONS and row != 2
                             ):  #color only row 2 of subcondition tables
                         color = self._computeColor(value)
                         if color:
                             newItem.setBackground(QBrush(color))
             except Exception, e:
                 logging.debug(
                     "TableWidgetController._updateDataTable(): Could not put value into widget item: %s\nError: %s"
                     % (value, e))
             if self.orientation == ORIENTATION_HORIZONTAL:
                 self.dataTableWidget.setItem(row, col, newItem)
             elif self.orientation == ORIENTATION_VERTICAL:
                 self.dataTableWidget.setItem(col, row, newItem)
コード例 #21
0
 def testReprFunction(self):
     reprPen = repr(QPen())
     self.assertTrue(reprPen.startswith("<PySide.QtGui.QPen"))
     reprBrush = repr(QBrush())
     self.assertTrue(reprBrush.startswith("<PySide.QtGui.QBrush"))
     reprObject = repr(QObject())
     self.assertTrue(reprObject.startswith("<PySide.QtCore.QObject"))
コード例 #22
0
 def paintEvent(self, pe):
     painter = QPainter(self)
     painter.save()
     gradient = QLinearGradient()
     gradient.setStart(self._grad_start)
     gradient.setFinalStop(self._grad_end)
     gradient.setColorAt(0, QColor(230, 230, 230))
     gradient.setColorAt(1, QColor(247, 247, 247))
     brush = QBrush(gradient)
     painter.setBrush(brush)
     pen = QPen(Qt.black)
     pen.setWidth(1)
     painter.setPen(pen)
     painter.drawPath(self._painter_path)
     painter.restore()
     font = QFont()
     font.setFamily("Tahoma")
     font.setPixelSize(11)
     font.setBold(True)
     pen = QPen(Qt.darkGray)
     painter.setPen(pen)
     painter.setFont(font)
     self_rect = QRect(self.rect())
     self_rect.moveTo(self._hor_margin, self._ver_margin // 2)
     painter.drawText(self_rect, Qt.AlignLeft, self._text)
コード例 #23
0
ファイル: bars_chart.py プロジェクト: wiz21b/koi
    def _draw_serie(self, painter, ndx_serie, color):

        serie = self.data[ndx_serie]

        #mainlog.debug(serie)

        fill_color = QColor(color)
        fill_color.setAlpha(64)
        brush = QBrush(fill_color)
        pen = QPen()
        pen.setCapStyle(Qt.SquareCap)
        pen.setColor(color)

        qp = QPainterPath()
        painter.setPen(pen)

        for i in range(len(serie)):
            x, y_top, y_below = self._item_coordinates(i)

            h = max(1, float(y_top - y_below - 1))
            qp.addRect( x,
                        float(self.y_base-y_top),
                        float(self.bar_width),
                        h)

        painter.fillPath(qp,brush)
        painter.drawPath(qp)

        #mainlog.debug("Drawing peak values, juste before {}".format(self._peak_values))
        if self._peak_values:
            #mainlog.debug("Drawing peak values")
            self._draw_peak_values(painter, self._peak_values )
コード例 #24
0
    def __init__(self, title=None):
        super(TitleWidget, self).__init__()

        if sys.platform.startswith("darwin"):
            color1 = QColor(230, 230, 230, 255)
            color2 = QColor(177, 177, 177, 255)

            gradient = QLinearGradient()
            gradient.setStart(0, 0)
            gradient.setFinalStop(0, TitleWidget.TitleHeight)
            gradient.setColorAt(0, color1)
            gradient.setColorAt(1, color2)

            brush = QBrush(gradient)
            palette = QPalette()
            palette.setBrush(QPalette.Background, brush)
            self.setPalette(palette)
            self.setAutoFillBackground(True)

        self.setMaximumHeight(TitleWidget.TitleHeight)
        self.setMinimumHeight(TitleWidget.TitleHeight)

        self.titleLabel = QLabel("", parent=self)
        font = self.titleLabel.font()
        font.setPixelSize(11)
        self.titleLabel.setFont(font)
        self.titleLabel.setAlignment(Qt.AlignCenter)
        self.titleLabel.setText(title)

        layout = QVBoxLayout()
        layout.setSpacing(0)
        layout.setContentsMargins(0, 0, 0, 0)
        layout.addWidget(self.titleLabel)
        self.setLayout(layout)
コード例 #25
0
ファイル: led_editor.py プロジェクト: waffle-iron/pychron
    def init(self, parent):
        """
        """
        rad = self.factory.radius
        if not rad:
            rad = 20

        if self.control is None:
            self.control = qtLED()
            scene = QGraphicsScene()
            #             self.control.setStyleSheet("qtLED { border-style: none; }");
            #             self.control.setAutoFillBackground(True)

            # system background color
            scene.setBackgroundBrush(QBrush(QColor(237, 237, 237)))
            self.control.setStyleSheet("border: 0px")
            self.control.setMaximumWidth(rad+15)
            self.control.setMaximumHeight(rad+15)

            x, y = 10, 10
            cx = x + rad / 1.75
            cy = y + rad / 1.75

            brush = self.get_color(self.value.state, cx, cy, rad / 2)
            pen = QPen()
            pen.setWidth(0)
            self.led = scene.addEllipse(x, y, rad, rad,
                                        pen=pen,
                                        brush=brush
                                        )

            self.control.setScene(scene)

            self.value.on_trait_change(self.update_object, 'state')
コード例 #26
0
    def paint(self, painter, option, widget=None):
        """QGraphicsRectItem virtual
        """
        # TODO LH Is there a way to clip to overlapping
        # QAbstractGraphicsItems with a larger zorder

        # TODO LH Get pixmap without tight coupling to scene
        painter.drawPixmap(self.boundingRect(),
                           self.scene().pixmap, self.sceneBoundingRect())

        with painter_state(painter):
            # Zero thickness indicates a cosmetic pen, which is drawn with the
            # same thickness regardless of the view's scale factor
            painter.setPen(QPen(self.colour, 0, Qt.SolidLine))
            r = self.boundingRect()
            painter.drawRect(r)

            if self._seeds:
                # Draw sub-segmentation seed points
                painter.setBrush(QBrush(Qt.black))
                painter.setPen(QPen(Qt.white, 5, Qt.SolidLine))
                for point in self._seeds:
                    painter.drawEllipse(point, 5, 5)

            if self.DRAW_INNER:
                painter.setPen(QPen(self.inner_colour, 1, Qt.SolidLine))
                r.adjust(1, 1, -1, -1)
                painter.drawRect(r)
コード例 #27
0
 def __init__(self, parent=None, ast=None):
     ast = ast or ogAST.State()
     ast.inputString = getattr(ast, 'via', None) or ast.inputString
     # Note: ast coordinates are in scene coordinates
     super(State, self).__init__(parent=parent,
                                 text=ast.inputString,
                                 x=ast.pos_x,
                                 y=ast.pos_y,
                                 hyperlink=ast.hyperlink)
     self.set_shape(ast.width, ast.height)
     self.setBrush(QBrush(QColor(255, 228, 213)))
     self.terminal_symbol = True
     if parent:
         try:
             # Map AST scene coordinates to get actual position
             self.setPos(self.pos() +
                         self.mapFromScene(ast.pos_x, ast.pos_y))
         except TypeError:
             self.update_position()
     else:
         # Use scene coordinates to position
         self.setPos(ast.pos_x, ast.pos_y)
     self.parser = ogParser
     if ast.comment:
         Comment(parent=self, ast=ast.comment)
コード例 #28
0
    def __init__(self, parent, scene, view):
        super(QNodesEditor, self).__init__(parent)

        self.scene = scene
        self.scene.installEventFilter(self)

        gridSize = 25
        gridMap = QPixmap(gridSize,gridSize)
        gridPainter = QPainter(gridMap)
        gridPainter.fillRect(0,0,gridSize,gridSize, QApplication.palette().window().color().darker(103))
        gridPainter.fillRect(1,1,gridSize-2,gridSize-2, QApplication.palette().window())
        gridPainter.end()
        self.scene.setBackgroundBrush( QBrush(gridMap) )

        originSize = 50
        originItem = QGraphicsPathItem()
        path = QPainterPath()
        path.moveTo(0,-originSize)
        path.lineTo(0,originSize)
        path.moveTo(-originSize,0)
        path.lineTo(originSize,0)
        originItem.setPath(path)
        originItem.setPen(QPen(QApplication.palette().window().color().darker(110),2))
        originItem.setZValue(-2)
        self.scene.addItem(originItem)

        self.view = view
        self.view.setDragMode(QGraphicsView.RubberBandDrag)
        self.view.setRenderHint(QPainter.Antialiasing)

        self.connection = None
コード例 #29
0
    def __init__(self, mw, parent=None):
        """
        Default class constructor.

        :param `mw`: Pointer to a application main window instance.
        :type `mw`: `MainWindow`_
        :param `parent`: Pointer to a parent widget instance.
        :type `parent`: `QWidget`_
        """
        super(MdiArea, self).__init__(parent)

        self.mainWin = mw
        self.gSpiralsImgPath = mw.gImgDir + os.sep + 'texture-spirals.png'
        self.gLogoSpiralsImgPath = mw.gImgDir + os.sep + 'logo-spirals.png'

        try:  #if QT_VERSION >= 0x040800
            self.setTabsClosable(True)
        except AttributeError:
            pass

        self.useLogo = False
        self.useTexture = False
        self.useColor = False

        self.bgLogo = QPixmap()
        self.bgTexture = QPixmap(self.gSpiralsImgPath)
        self.bgColor = QColor()

        self.bgLogo = QPixmap(self.gLogoSpiralsImgPath)

        # Brushes
        self.colorBrush = QBrush(QColor(EMBROIDERBLUE1))
        self.backgroundBrush = QBrush(QPixmap(self.gSpiralsImgPath))
        linearGrad = QLinearGradient(QPointF(0, 0), QPointF(400, 400))
        linearGrad.setColorAt(0, QColor(EMBROIDERBLUE1))
        linearGrad.setColorAt(1, QColor(EMBROIDERBLUE2))
        self.gradientBrush = QBrush(linearGrad)

        self.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded)
        self.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)
        self.setActivationOrder(QMdiArea.ActivationHistoryOrder)

        self.setFocusPolicy(Qt.WheelFocus)
        self.setFocus()

        self.setAcceptDrops(True)
        self.doSetDocumentMode(True)
コード例 #30
0
ファイル: lines_chart.py プロジェクト: wiz21b/koi
    def _draw_selected_items_in_series(self, painter):
        fm = painter.fontMetrics()

        pen = QPen()
        pen.setWidth(1)
        pen.setColor(Qt.GlobalColor.white)
        painter.setPen(pen)

        # We assume all series have the very same number of values
        # and all values on the same index are drawn on the same X
        # coordinate

        ndx_serie = self.best_serie_intra_ndx

        aesthetic_shift = 5

        if ndx_serie is not None:

            to_draw = []
            for i in range(len(self.data)):
                x, y = self._item_coordinates_lines(i, ndx_serie)
                #mainlog.debug("{} {}".format(ndx_serie,i))
                v = self.data[i][ndx_serie]

                text = str(int(v))

                to_draw.append( (self.y_base - y, text) )

            last_y = 100000
            for y, text in sorted( to_draw, key=lambda z : z[0], reverse=True):
                r = QRect(x + aesthetic_shift,0,1000,1000)
                bb = painter.boundingRect(r,Qt.AlignLeft,text)
                if bb.right() > self.width():
                    x = x - bb.width() - 2*aesthetic_shift# left align

                if y + bb.height() > last_y:
                    y = last_y - bb.height()

                fill_color = QColor(16, 16, 48)
                fill_color.setAlpha(196)
                brush = QBrush(fill_color)
                margin = 2
                r = QRect(x + aesthetic_shift - margin,
                          y - aesthetic_shift - bb.height() - margin,
                          bb.width() + 2*margin,
                          bb.height() + 2*margin)
                painter.fillRect(r, brush)

                painter.drawText(x + aesthetic_shift,
                                 y - aesthetic_shift,
                                 text)

                last_y = y

            x, y = self._item_coordinates_lines(0, ndx_serie)
            qp = QPainterPath()
            qp.moveTo(x, self.y_base)
            qp.lineTo(x, self.y_base - self.total_height)
            painter.drawPath(qp)
コード例 #31
0
    def __init__(self, conditional_to=False, two_way=False, conditional_from=False):
        QGraphicsItem.__init__(self)

        self.node_from = None
        self.node_to = None
        self.conditional_to = conditional_to
        self.conditional_from = conditional_from

        if conditional_to:
            self.pen = QPen(CONDITIONAL_TRANSITION_COLOR)
            self.brush = QBrush(CONDITIONAL_TRANSITION_COLOR)
        else:
            self.pen = QPen(NON_CONDITIONAL_TRANSITION_COLOR)
            self.brush = QBrush(NON_CONDITIONAL_TRANSITION_COLOR)

        self.arrow_length = 10
        self.two_way = two_way
コード例 #32
0
 def background_color_eval(self, ndx):
     # print self.current_timetrack,self.objects[ndx.row()]
     if self.isIndexValid(ndx) and ndx.row() < len(
             self.objects) and self.objects[ndx.row()] and self.objects[
                 ndx.row()].timetrack == self.current_timetrack:
         return QBrush(Qt.GlobalColor.green)
     else:
         return None
コード例 #33
0
ファイル: led_editor.py プロジェクト: stephen-e-cox/pychron
    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
コード例 #34
0
    def draw(self, painter, scale):
        painter.save()
        if not self.p1.isNull() and not self.p2.isNull():
            painter.setPen(
                QPen(
                    QBrush(
                        QColor(232, 109, 21) if self.state is not self.
                        control else QColor(21, 144, 232)),
                    self.lineWidth(scale), Qt.SolidLine))
            painter.setBrush(QBrush(QColor(21, 144, 232, 150)))
            painter.drawRect(QRect(self.p1, self.p2))

            self.drawControlPoint(painter, self.p1, QColor(31, 174, 222),
                                  scale)
            self.drawControlPoint(painter, self.p2, QColor(222, 79, 31), scale)

        Figure.draw(self, painter, scale)
        painter.restore()
コード例 #35
0
ファイル: LoginUI.py プロジェクト: tigerSI/HMS_project
 def initUI(self):
     posX, posY, sizeW, sizeH = s.GEOMETRY_MAINWIDOW
     self.setGeometry(posX, posY, sizeW, sizeH)
     self.setWindowTitle("Hospital Management System")
     palette = QPalette()
     palette.setBrush(QPalette.Background, QBrush(QPixmap(s.PATH_IMG_BG_LOGIN)))
     self.setPalette(palette)
     self.initButton()
     self.forDev()
コード例 #36
0
ファイル: LoginUI.py プロジェクト: tigerSI/HMS_project
 def initButton(self):
     loader = QUiLoader()
     form = loader.load('RSC/loginUI/Widget_LoginUI.ui', self)
     self.user_id = form.findChild(QLineEdit, "lineEdit_username")
     self.password = form.findChild(QLineEdit, "lineEdit_password")
     self.login_button = form.findChild(QPushButton, "button_login")
     self.login_button.clicked.connect(self.logIn)
     palette = QPalette()
     palette.setBrush(QPalette.Background, QBrush(QPixmap(s.PATH_IMG_BG_LOGIN)))
     self.setPalette(palette)
コード例 #37
0
ファイル: stream.py プロジェクト: nisseblink/livestreamer-ui
    def is_online(self, tableWidgetItem):

        Stream.clear_streams()

        process = QProcess()

        self.process = process
        self.table_widget_item = tableWidgetItem

        arguments = ["--json"] + self.arguments

        process.setProcessChannelMode(QProcess.MergedChannels)
        process.start("livestreamer", arguments)
        process.readyReadStandardOutput.connect(self.is_online_callback)

        brush = QBrush(Qt.SolidPattern)
        color = QColor(255, 255, 255)  # white
        brush.setColor(color)
        tableWidgetItem.setBackground(brush)
        tableWidgetItem.setText("Checking..")

        Stream.ALL_STREAMS.append(self)
コード例 #38
0
class SelectBox(QRubberBand):
    """
    Subclass of `QRubberBand`_

    TOWRITE

    """
    def __init__(self, s, parent=None):
        """
        Default class constructor.

        :param `s`: TOWRITE
        :type `s`: QRubberBand.Shape
        :param `parent`: Pointer to a parent widget instance.
        :type `parent`: `QWidget`_
        """
        super(SelectBox, self).__init__(s, parent)

        # private
        self._leftBrushColor = QColor()
        self._rightBrushColor = QColor()
        self._leftPenColor = QColor()
        self._rightPenColor = QColor()
        self._alpha = 255  # quint8  #: TODO: what is the initial int?

        self._dirBrush = QBrush()
        self._leftBrush = QBrush()
        self._rightBrush = QBrush()

        self._dirPen = QPen()
        self._leftPen = QPen()
        self._rightPen = QPen()

        self._boxDir = False  #: TODO: is this initial bool value right?

        # Default values
        self.setColors(QColor(Qt.darkGreen), QColor(Qt.green), QColor(Qt.darkBlue), QColor(Qt.blue), 32)

    def paintEvent(self, event):
        """
        Handles the ``paintEvent`` event for :class:`SelectBox`.

        :param `event`: A `QPaintEvent`_ to be processed.
        """
        painter = QPainter(self)
        painter.setPen(self._dirPen)
        width, height = self.width(), self.height()
        painter.fillRect(0, 0, width - 1, height - 1, self._dirBrush)
        painter.drawRect(0, 0, width - 1, height - 1)

    def forceRepaint(self):
        """
        Force repaint the rubberband.

        .. NOTE:: HACK: Take that QRubberBand!
        """
        # HACK: Take that QRubberBand!
        hack = self.size()  # QSize
        self.resize(hack + QSize(1, 1))
        self.resize(hack)

    # Slots ------------------------------------------------------------------

    @Slot(int)
    def setDirection(self, dir):
        """
        TOWRITE

        :param `dir`: TOWRITE
        :type `dir`: int
        """
        if not dir:
            self._dirPen = self._leftPen
            self._dirBrush = self._leftBrush
        else:
            self._dirPen = self._rightPen
            self._dirBrush = self._rightBrush
        self._boxDir = dir

    @Slot(QColor, QColor, QColor, QColor, int)
    def setColors(self, colorL, fillL, colorR, fillR, newAlpha):
        """
        TOWRITE

        :param `colorL`: TOWRITE
        :type `colorL`: `QColor`_
        :param `fillL`: TOWRITE
        :type `fillL`: `QColor`_
        :param `colorR`: TOWRITE
        :type `colorR`: `QColor`_
        :param `fillR`: TOWRITE
        :type `fillR`: `QColor`_
        :param `newAlpha`: TOWRITE
        :type `newAlpha`: int
        """
        qDebug("SelectBox setColors()")
        self._alpha = newAlpha

        self._leftPenColor = colorL  # TODO: allow customization
        self._leftBrushColor = QColor(fillL.red(), fillL.green(), fillL.blue(), self._alpha)
        self._rightPenColor = colorR  # TODO: allow customization
        self._rightBrushColor = QColor(fillR.red(), fillR.green(), fillR.blue(), self._alpha)

        self._leftPen.setColor(self._leftPenColor)
        self._leftPen.setStyle(Qt.DashLine)
        self._leftBrush.setStyle(Qt.SolidPattern)
        self._leftBrush.setColor(self._leftBrushColor)

        self._rightPen.setColor(self._rightPenColor)
        self._rightPen.setStyle(Qt.SolidLine)
        self._rightBrush.setStyle(Qt.SolidPattern)
        self._rightBrush.setColor(self._rightBrushColor)

        if not self._boxDir:
            self._dirPen = self._leftPen
            self._dirBrush = self._leftBrush
        else:
            self._dirPen = self._rightPen
            self._dirBrush = self._rightBrush

        self.forceRepaint()