Exemplo n.º 1
0
    def paintEvent(self, paint_event):
        QFrame.paintEvent(self, paint_event)
        painter = QPainter(self)
        painter.setRenderHint(QPainter.Antialiasing)

        w = self.width()
        h = self.height()

        if self.horizontal:
            self.min_marker = QRectF(w * self.min_value, 4, self.size, self.size)
            self.max_marker = QRectF(w * self.max_value - self.size - 1, 4, self.size, self.size)
        else:
            self.min_marker = QRectF(4, h - h * self.min_value - self.size - 1, self.size, self.size)
            self.max_marker = QRectF(4, h - h * self.max_value, self.size, self.size)

        pen = painter.pen()
        pen.setWidth(0)
        pen.setColor(QApplication.palette().background().color().dark())
        painter.setPen(pen)

        painter.setBrush(self.min_marker_brush)
        painter.drawPie(self.min_marker, self.tilt * 16, 180 * 16)

        painter.setBrush(self.max_marker_brush)
        painter.drawPie(self.max_marker, self.tilt * 16, -180 * 16)
Exemplo n.º 2
0
    def paintEvent(self, paint_event):
        QFrame.paintEvent(self, paint_event)
        painter = QPainter(self)
        painter.setRenderHint(QPainter.Antialiasing)

        w = self.width()
        h = self.height()

        if self.horizontal:
            self.min_marker = QRectF(w * self.min_value, 4, self.size,
                                     self.size)
            self.max_marker = QRectF(w * self.max_value - self.size - 1, 4,
                                     self.size, self.size)
        else:
            self.min_marker = QRectF(4, h - h * self.min_value - self.size - 1,
                                     self.size, self.size)
            self.max_marker = QRectF(4, h - h * self.max_value, self.size,
                                     self.size)

        pen = painter.pen()
        pen.setWidth(0)
        pen.setColor(QApplication.palette().background().color().dark())
        painter.setPen(pen)

        painter.setBrush(self.min_marker_brush)
        painter.drawPie(self.min_marker, self.tilt * 16, 180 * 16)

        painter.setBrush(self.max_marker_brush)
        painter.drawPie(self.max_marker, self.tilt * 16, -180 * 16)
Exemplo n.º 3
0
	def __modifyProgressPixmap(self, pixmap, done):
		alpha = pixmap.alphaChannel()
		painter = QPainter()
		painter.begin(alpha)
		painter.setRenderHint(QPainter.Antialiasing)
		painter.setPen(Qt.white)
		painter.setBrush(QBrush(QColor(0, 0, 0, 196)))
		rect = QRect(int(float(pixmap.rect().width()) * (-0.5)), int(float(pixmap.rect().height()) * (-0.5)), pixmap.rect().width() * 2, pixmap.rect().height() * 2)
		painter.drawPie(rect, 1440, ((100 - done) * 360 * 16) / 100)
		painter.end()
		pixmap.setAlphaChannel(alpha)
Exemplo n.º 4
0
 def paintEvent(self, event):
     # import math
     bgcolor = self.palette().color(QPalette.Background)
     pen = QPen(bgcolor, 7, QtCore.Qt.SolidLine)
     qp = QPainter()
     qp.begin(self)
     qp.setPen(pen)
     qp.setRenderHint(QPainter.Antialiasing)
     qp.setBrush(Qt.gray)
     for i in range(self.n):
         alpha = int(16 * 360 * i / self.n)
         alpha2 = int(16 * 360 * 1 / self.n)
         qp.setBrush(Qt.green if i < self.m else Qt.gray)
         qp.drawPie(self.R, alpha, alpha2)
     qp.end()
Exemplo n.º 5
0
    def paintEvent(self, event):
        painter = QPainter()
        painter.begin(self)
        painter.setRenderHint(QPainter.Antialiasing)
        # pen sets the edge color of the circles
        painter.setPen(QColor(20, 20, 20, 0))

        painter.setBrush(QBrush(QColor(255, 255, 255, 220)))
        x = 13
        y = 6
        r = 23
        rect = QRect(x, y, r, r)

        painter.drawEllipse(rect)

        painter.setBrush(QBrush(QColor(20, 20, 20, 100)))

        startAngle = 90 * 16
        spanAngle = -((self.currentPiece * self.step) * 16)

        painter.drawPie(rect, startAngle, spanAngle)

        painter.end()
Exemplo n.º 6
0
    def paintEvent(self, event):
        """Adapted from http://doc.qt.io/qt-5/qtwidgets-widgets-analogclock-example.html"""
        HOURHAND = QPolygon([QPoint(7, 8), QPoint(-7, 8), QPoint(0, -55)])
        MINUTEHAND = QPolygon([QPoint(7, 8), QPoint(-7, 8), QPoint(0, -87)])
        HOURCOLOR = QColor(Qt.black)
        MINUTECOLOR = QColor(0x11, 0x11, 0x11, 0xAA)

        painter = QPainter(self)
        painter.setRenderHint(QPainter.Antialiasing)
        painter.translate(self.width() / 2, self.height() / 2)
        SIDE = 200
        side = min(self.width(), self.height())
        painter.scale(side / SIDE, side / SIDE)

        # Background (night/day)
        if self._time_to is not None:
            time = self._time_to.time()
            hour_offset = time.hour() + time.minute() / 60
            DAY, NIGHT = QColor(Qt.white), QColor('#5555ff')
            if 7 <= hour_offset <= 19:
                background = DAY
            elif 6 <= hour_offset <= 7:
                palette = GradientPaletteGenerator(NIGHT, DAY)
                background = palette[(hour_offset - 6) / (7 - 6)]
            elif 19 <= hour_offset <= 20:
                palette = GradientPaletteGenerator(DAY, NIGHT)
                background = palette[(hour_offset - 19) / (20 - 19)]
            else:
                assert hour_offset < 7 or hour_offset > 20
                background = NIGHT
            painter.setBrush(QBrush(background))
            painter.setPen(HOURCOLOR)
            painter.drawEllipse(-SIDE / 2, -SIDE / 2, SIDE, SIDE)

        # Minute tickmarks
        painter.save()
        painter.setPen(MINUTECOLOR)
        for j in range(60):
            painter.drawLine(94, 0, 97, 0)
            painter.rotate(6)
        painter.restore()

        # Hour tickmarks
        painter.save()
        painter.setPen(HOURCOLOR)
        for _ in range(12):
            painter.drawLine(88, 0, 98, 0)
            painter.rotate(30)
        painter.restore()

        # Hour span
        if self._time_from is not None:
            time_from = self._time_from.time()
            time_to = self._time_to.time()
            if time_from.secsTo(
                    time_to) / 3600 > .2:  # Don't draw really small intervals
                hour_from = (time_from.hour() +
                             time_from.minute() / 60) % 12 - 3
                hour_to = (time_to.hour() + time_to.minute() / 60) % 12 - 3
                startAngle = -hour_to * 30 * 16
                spanAngle = -hour_from * 30 * 16 - startAngle
                color = QColor(0xFF, 0xFF, 0, 0xAA)
                painter.save()
                painter.setBrush(QBrush(color, Qt.DiagCrossPattern))
                painter.setPen(color.darker(180))
                painter.drawPie(-SIDE / 2, -SIDE / 2, SIDE, SIDE, startAngle,
                                spanAngle)
                painter.restore()

        # Hour and minute hand
        if self._time_to is not None:
            time = self._time_to.time()

            painter.setPen(Qt.NoPen)

            painter.save()
            painter.setBrush(HOURCOLOR)
            painter.rotate(30 * (time.hour() + time.minute() / 60))
            painter.drawConvexPolygon(HOURHAND)
            painter.restore()

            painter.save()
            painter.setBrush(MINUTECOLOR)
            painter.rotate(6 * (time.minute() + time.second() / 60))
            painter.drawConvexPolygon(MINUTEHAND)
            painter.restore()
Exemplo n.º 7
0
    def paintEvent(self, event):
        """Adapted from http://doc.qt.io/qt-5/qtwidgets-widgets-analogclock-example.html"""
        HOURHAND = QPolygon([QPoint(7, 8), QPoint(-7, 8), QPoint(0, -55)])
        MINUTEHAND = QPolygon([QPoint(7, 8), QPoint(-7, 8), QPoint(0, -87)])
        HOURCOLOR = QColor(Qt.black)
        MINUTECOLOR = QColor(0x11, 0x11, 0x11, 0xAA)

        painter = QPainter(self)
        painter.setRenderHint(QPainter.Antialiasing)
        painter.translate(self.width() / 2, self.height() / 2)
        SIDE = 200
        side = min(self.width(), self.height())
        painter.scale(side / SIDE, side / SIDE)

        # Background (night/day)
        if self._time_to is not None:
            time = self._time_to.time()
            hour_offset = time.hour() + time.minute() / 60
            DAY, NIGHT = QColor(Qt.white), QColor('#5555ff')
            if 7 <= hour_offset <= 19:
                background = DAY
            elif 6 <= hour_offset <= 7:
                palette = GradientPaletteGenerator(NIGHT, DAY)
                background = palette[(hour_offset - 6) / (7 - 6)]
            elif 19 <= hour_offset <= 20:
                palette = GradientPaletteGenerator(DAY, NIGHT)
                background = palette[(hour_offset - 19) / (20 - 19)]
            else:
                assert hour_offset < 7 or hour_offset > 20
                background = NIGHT
            painter.setBrush(QBrush(background))
            painter.setPen(HOURCOLOR)
            painter.drawEllipse(-SIDE / 2, -SIDE / 2, SIDE, SIDE)

        # Minute tickmarks
        painter.save()
        painter.setPen(MINUTECOLOR)
        for j in range(60):
            painter.drawLine(94, 0, 97, 0)
            painter.rotate(6)
        painter.restore()

        # Hour tickmarks
        painter.save()
        painter.setPen(HOURCOLOR)
        for _ in range(12):
            painter.drawLine(88, 0, 98, 0)
            painter.rotate(30)
        painter.restore()

        # Hour span
        if self._time_from is not None:
            time_from = self._time_from.time()
            time_to = self._time_to.time()
            if time_from.secsTo(time_to) / 3600 > .2:  # Don't draw really small intervals
                hour_from = (time_from.hour() + time_from.minute() / 60) % 12 - 3
                hour_to = (time_to.hour() + time_to.minute() / 60) % 12 - 3
                startAngle = -hour_to * 30 * 16
                spanAngle = -hour_from * 30 * 16 - startAngle
                color = QColor(0xFF, 0xFF, 0, 0xAA)
                painter.save()
                painter.setBrush(QBrush(color, Qt.DiagCrossPattern))
                painter.setPen(color.darker(180))
                painter.drawPie(-SIDE / 2, -SIDE / 2, SIDE, SIDE, startAngle, spanAngle)
                painter.restore()

        # Hour and minute hand
        if self._time_to is not None:
            time = self._time_to.time()

            painter.setPen(Qt.NoPen)

            painter.save()
            painter.setBrush(HOURCOLOR)
            painter.rotate(30 * (time.hour() + time.minute() / 60))
            painter.drawConvexPolygon(HOURHAND)
            painter.restore()

            painter.save()
            painter.setBrush(MINUTECOLOR)
            painter.rotate(6 * (time.minute() + time.second() / 60))
            painter.drawConvexPolygon(MINUTEHAND)
            painter.restore()