예제 #1
0
    def draw_line_to(self, end_point):
        painter = QPainter(self.image)
        painter.setPen(QPen(self.pen_color, self.pen_width, Qt.SolidLine, Qt.RoundCap, Qt.RoundJoin))
        painter.drawLine(self.last_point/5, end_point/5)

        self.update()
        self.last_point = QPoint(end_point)
예제 #2
0
    def _drawMonthFrame(self):
        self.initMonthInfo()
        wi = self.month_info
        painter = QPainter(self)

        pen = painter.pen()
        pen.setWidth(Var.line_width)
        painter.setPen(pen)

        for coord in wi.paint_base_lines:
            painter.drawLine(*coord)

        # Draw selections
        for selection in wi.selections():
            painter.fillRect(*selection)


        # Draw dates
        font = painter.font()
        font.setPointSize(wi.cell_height/8)
        painter.setFont(font)

        for cell_id in range(42):
            x, y = wi.getCoordinate(cell_id)
            x += wi.cell_width * 74/100
            y += wi.cell_height/7
            
            day = wi.getDay(cell_id)

            painter.drawText(QPointF(x, y), QString(str(day)))
예제 #3
0
    def paintEvent(self, event):
        painter = QPainter()
        painter.begin(self)
        painter.setRenderHint(QPainter.Antialiasing)
        painter.fillRect(event.rect(), QBrush(QColor(255, 255, 255, 127)))
        painter.setPen(QPen(Qt.NoPen))

        for i in xrange(6):
            x_pos = self.width() / 2 + 30 * \
                math.cos(2 * math.pi * i / 6.0) - 10
            y_pos = self.height() / 2 + 30 * \
                math.sin(2 * math.pi * i / 6.0) - 10
            if (self.counter / 5) % 6 == i:
                linear_gradient = QLinearGradient(
                    x_pos + 10, x_pos, y_pos + 10, y_pos)
                linear_gradient.setColorAt(0, QColor(135, 206, 250))
                linear_gradient.setColorAt(1, QColor(0, 0, 128))
                painter.setBrush(QBrush(linear_gradient))
            else:
                linear_gradient = QLinearGradient(
                    x_pos - 10, x_pos, y_pos + 10, y_pos)
                linear_gradient.setColorAt(0, QColor(105, 105, 105))
                linear_gradient.setColorAt(1, QColor(0, 0, 0))
                painter.setBrush(QBrush(linear_gradient))
            painter.drawEllipse(
                x_pos,
                y_pos,
                20, 20)

        painter.end()
예제 #4
0
 def paintEvent(self, e):
     painter = QPainter(self)
     painter.setPen(QColor(self._backgroundColor))
     painter.setBrush(QColor(self._backgroundColor))
     painter.drawRect(0, 0, self.width(), self.height())
     painter.end()
     QFrame.paintEvent(self, e)
예제 #5
0
파일: config.py 프로젝트: 675801717/orange3
def splash_screen():
    """
    """
    pm = QPixmap(
        pkg_resources.resource_filename(
            __name__, "icons/orange-splash-screen.png")
    )

    version = QCoreApplication.applicationVersion()
    size = 21 if len(version) < 5 else 16
    font = QFont("Helvetica")
    font.setPixelSize(size)
    font.setBold(True)
    font.setItalic(True)
    font.setLetterSpacing(QFont.AbsoluteSpacing, 2)
    metrics = QFontMetrics(font)
    br = metrics.boundingRect(version).adjusted(-5, 0, 5, 0)
    br.moveCenter(QPoint(436, 224))

    p = QPainter(pm)
    p.setRenderHint(QPainter.Antialiasing)
    p.setRenderHint(QPainter.TextAntialiasing)
    p.setFont(font)
    p.setPen(QColor("#231F20"))
    p.drawText(br, Qt.AlignCenter, version)
    p.end()
    return pm, QRect(88, 193, 200, 20)
예제 #6
0
 def paintEvent(self, ev):
     """Called when paint is needed, finds out which page to magnify."""
     layout = self.parent().surface().pageLayout()
     pos = self.geometry().center() - self.parent().surface().pos()
     page = layout.pageAt(pos)
     if not page:
         return
     pagePos = pos - page.pos()
     
     newPage = Page(page, self._scale)
     if not newPage.same_page(self._page):
         if self._page:
             self._page.magnifier = None
         self._page = newPage
         self._page.magnifier = self
     
     relx = pagePos.x() / float(page.width())
     rely = pagePos.y() / float(page.height())
     
     image = cache.image(self._page)
     img_rect = QRect(self.rect())
     if not image:
         cache.generate(self._page)
         image = cache.image(self._page, False)
         if image:
             img_rect.setWidth(self.width() * image.width() / self._page.width())
             img_rect.setHeight(self.height() * image.height() / self._page.height())
     if image:
         img_rect.moveCenter(QPoint(relx * image.width(), rely * image.height()))
         p = QPainter(self)
         p.drawImage(self.rect(), image, img_rect)
         p.setRenderHint(QPainter.Antialiasing, True)
         p.setPen(QPen(QColor(192, 192, 192, 128), 6))
         p.drawEllipse(self.rect().adjusted(2, 2, -2, -2))
	def drawROIBoxes(self, image):
		#print(self.frame_data)
		if not isinstance(self.frame_data, pd.DataFrame) or len(self.frame_data) == 0 \
		or not self.label_type in self.frame_data:
			return 
		 			
		self.img_h_ratio = image.height()/self.image_height;
		self.img_w_ratio = image.width()/self.image_width;

		painter = QPainter()
		painter.begin(image)
		for row_id, row_data in self.frame_data.iterrows():
			x = row_data['coord_x']*self.img_h_ratio
			y = row_data['coord_y']*self.img_w_ratio
			#check if the coordinates are nan
			if not (x == x) or  not (y == y): 
				continue

			x = int(x)
			y = int(y)
			c = self.wlabC[int(row_data[self.label_type])]
			
			painter.setPen(c)
			painter.setFont(QFont('Decorative', 10))
			
			painter.drawText(x, y, str(int(row_data[self.worm_index_type])))

			bb = row_data['roi_size']*self.img_w_ratio
			painter.drawRect(x-bb/2, y-bb/2, bb, bb);
		painter.end()
예제 #8
0
    def paintEvent(self, event):
        if not self.displayedWhenStopped and not self.isAnimated():
            return

        width = min(self.width(), self.height())

        p = QPainter(self)
        p.setRenderHint(QPainter.Antialiasing)

        outerRadius = (width-1) * 0.5
        innerRadius = (width-1) * 0.5 * 0.38

        capsuleHeight = outerRadius - innerRadius
        capsuleWidth  = capsuleHeight * 0.23 if width > 32 else capsuleHeight * 0.35
        capsuleRadius = capsuleWidth / 2

        for i in range(12):
            color = QColor(self.color)
            color.setAlphaF(float(1.0 - float(i / 12.0)))
            p.setPen(Qt.NoPen)
            p.setBrush(color)
            p.save()
            p.translate(self.rect().center())
            p.rotate(self.angle - float(i * 30.0))
            p.drawRoundedRect(-capsuleWidth * 0.5,\
                              -(innerRadius + capsuleHeight),\
                              capsuleWidth,\
                              capsuleHeight,\
                              capsuleRadius,\
                              capsuleRadius)
            p.restore()
예제 #9
0
 def paintEvent(self, event):
     QWidget.paintEvent(self, event)
     painter = QPainter(self)
     painter.setBrush(QBrush(QColor(Qt.black)))
     painter.setPen(QPen())
     painter.setOpacity(self.value)
     painter.drawRect(self.rect())
def draw_centering_guides(image, target_x, target_y, target_w, guide_h):
  
  left_x = target_x - (target_w / 2.0)
  right_x = left_x + target_w
  
  top_y = target_y
  bottom_y = top_y + guide_h
  
  new_img = image.copy()
  
  if not new_img.format() is QImage.Format_ARGB32_Premultiplied:
    new_img = new_img.convertToFormat(QImage.Format_ARGB32_Premultiplied)
  
  painter = QPainter(new_img)
  
  pen = painter.pen()
  pen.setColor(QColor(255, 0, 0))
  painter.setPen(pen)
  
  painter.drawLine(left_x, top_y, left_x, bottom_y)
  painter.drawLine(right_x, top_y, right_x, bottom_y)
  
  painter.end()
  
  return new_img
예제 #11
0
 def paintEvent(self, e):
     painter = QPainter()
     reactantside = ""
     productside = ""
     reactantside += self._CurrentReaction.GetReactants()[0].GetFormula()
     for x in range(1, len(self._CurrentReaction.GetReactants())):
         reactant = self._CurrentReaction.GetReactants()[x]
         formula = reactant.GetFormula()
         moles = reactant.GetInitialMoles()
         if moles > 0:
             reactantside += " + "+formula
     productside += self._CurrentReaction.GetProducts()[0].GetFormula()
     for x in range(1, len(self._CurrentReaction.GetProducts())):
         product = self._CurrentReaction.GetProducts()[x]
         formula = product.GetFormula()
         moles = product.GetInitialMoles()
         if moles > 0:
             productside += " + "+formula
     painter.begin(self)
     painter.setFont(QFont("Arial", 20, 50, False))
     painter.setPen(QPen(Qt.red, 2, Qt.SolidLine))
     painter.drawText(376 - (len(reactantside) * 15), 40, reactantside)
     target = QRectF(378, 20, 44, 32)
     arrows = QPixmap("assets/double arrow.png")
     portion = QRectF(10, 0, 44, 32)
     painter.drawPixmap(target, arrows, portion)
     painter.setPen(QPen(Qt.blue, 2, Qt.SolidLine))
     painter.drawText(425, 40, productside)
     painter.end()
예제 #12
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)
예제 #13
0
    def paintEvent(self, event):
        painter = QPainter(self)
        icon = self.icon_pressed if self.isDown() else self.icon
        if icon is not None:
            x = (self.width() - icon.width()) / 2
            y = (self.height() - icon.height()) / 2
            painter.drawPixmap(x, y, icon)
        else:
            width = self.width()
            height = self.height()

            padding = width / 5
            radius = width - 2*padding

            palette = self.palette()

            # Mid is darker than Dark. Go figure... -Dan
            bg_color = palette.color(QPalette.Mid) if self.isDown() else palette.color(QPalette.Dark)
            fg_color = palette.color(QPalette.Window) # or QPalette.Base for white

            painter.setRenderHint(QPainter.Antialiasing, True)
            painter.setBrush(bg_color)
            painter.setPen(bg_color)
            painter.drawEllipse(padding, padding, radius, radius)

            padding = padding * 2
            painter.setPen(fg_color)
            painter.drawLine(padding, padding, width-padding, height-padding)
            painter.drawLine(padding, height-padding, width-padding, padding)
예제 #14
0
 def paintEvent( self, event ):
     """
     Overloads the paint event for this menu to draw its title based on its \
     show title property.
     
     :param      event | <QPaintEvent>
     """
     super(XMenu, self).paintEvent(event)
     
     if ( self.showTitle() ):
         painter = QPainter()
         painter.begin(self)
         
         palette = self.palette()
         
         painter.setBrush(palette.color(palette.Button))
         painter.setPen(Qt.NoPen)
         painter.drawRect(1, 1, self.width() - 2, 22)
         
         painter.setBrush(Qt.NoBrush)
         painter.setPen(palette.color(palette.ButtonText))
         painter.drawText(1, 1, self.width() - 2, 22, 
                          Qt.AlignCenter, self.title())
         
         painter.end()
예제 #15
0
 def paintEvent( self, event ):
     """
     Overloads the paint event to draw rounded edges on this widget.
     
     :param      event | <QPaintEvent>
     """
     super(XRolloutItem, self).paintEvent(event)
     
     painter = QPainter()
     painter.begin(self)
     
     w = self.width() - 3
     h = self.height() - 3
     
     color = self.palette().color(QPalette.Midlight)
     color = color.darker(180)
     pen = QPen(color)
     pen.setWidthF(0.5)
     
     painter.setPen(pen)
     painter.setBrush(self.palette().color(QPalette.Midlight))
     painter.setRenderHint(QPainter.Antialiasing)
     painter.drawRoundedRect(1, 1, w, h, 10, 10)
     
     painter.end()
예제 #16
0
    def paintEvent(self, e):
        Part.paintEvent(self, e)
        painter = QPainter(self)
        color = QColor(self._base)
        color.setAlpha(200)
        painter.setPen(color.dark(150))
        painter.setBrush(color.dark(115))
        painter.setRenderHint(QPainter.Antialiasing)

        painter.drawEllipse(11, 22, 10, 10)
        
        rect = QRectF(25, 17, 7, 20)
        painter.drawChord(rect, 270 * 16, 180 * 16)
        
        rect = QRectF(40, 11, 10, 30)
        painter.drawChord(rect, 270 * 16, 180 * 16)

        painter.drawEllipse(63, 14, 5, 5)
        painter.drawEllipse(63, 35, 5, 5)
        painter.drawEllipse(81, 14, 5, 5)
        painter.drawEllipse(81, 35, 5, 5)
        
        painter = None
        if self.data is None:
            text = None
        else:
            text = self.data.name        
        self.drawText(text)
예제 #17
0
 def paintEvent(self, event):
     """
     Overloads the paint event to handle painting pointers for the popup \
     mode.
     
     :param      event | <QPaintEvent>
     """
     # use the base technique for the dialog mode
     if self.currentMode() == XPopupWidget.Mode.Dialog:
         super(XPopupWidget, self).paintEvent(event)
         return
     
     # setup the coloring options
     palette = self.palette()
     
     painter = QPainter()
     painter.begin(self)
     
     pen = QPen(palette.color(palette.Window).darker(130))
     pen.setWidthF(1.75)
     painter.setPen(pen)
     painter.setRenderHint(painter.Antialiasing)
     painter.setBrush(palette.color(palette.Window))
     painter.drawPath(self.borderPath())
     painter.end()
예제 #18
0
 def paintEvent(self, e):
     painter = QPainter(self)
     painter.setPen(self.color)
     painter.setBrush(Qt.NoBrush)
     rect = QRect(self.x,self.y,self.w,self.h)
     painter.drawRect(rect)
     QWidget.paintEvent(self, e)
예제 #19
0
    def paintEvent(self, event):
        """QWidget.paintEvent() implementation
        """
        painter = QPainter(self)
        painter.fillRect(event.rect(), self.palette().color(QPalette.Window))
        painter.setPen(Qt.black)

        block = self._qpart.firstVisibleBlock()
        blockNumber = block.blockNumber()
        top = int(self._qpart.blockBoundingGeometry(block).translated(self._qpart.contentOffset()).top())
        bottom = top + int(self._qpart.blockBoundingRect(block).height())
        singleBlockHeight = self._qpart.cursorRect().height()

        width = None

        boundingRect = self._qpart.blockBoundingRect(block)
        while block.isValid() and top <= event.rect().bottom():
            if block.isVisible() and bottom >= event.rect().top():
                number = str(blockNumber + 1)
                painter.drawText(0, top, self.width() - self._RIGHT_MARGIN, self._qpart.fontMetrics().height(),
                                 Qt.AlignRight, number)
                if boundingRect.height() >= singleBlockHeight * 2:  # wrapped block
                    if width is None:
                        width = self.width()  # laizy calculation
                    painter.fillRect(1, top + singleBlockHeight,
                                     width - 2, boundingRect.height() - singleBlockHeight - 2,
                                     Qt.darkGreen)

            block = block.next()
            boundingRect = self._qpart.blockBoundingRect(block)
            top = bottom
            bottom = top + int(boundingRect.height())
            blockNumber += 1
예제 #20
0
 def updateCircle(self, s):
     size = s * self.zoom
     pixmap = QPixmap(self.width(), self.height())
     pixmap.fill(Qt.transparent)
     #painter ellipse 1
     painter = QPainter()
     painter.begin(pixmap)
     painter.setRenderHint(QPainter.Antialiasing)
     pen = QPen(Qt.red)
     pen.setWidth(3)
     painter.setPen(pen)
     brush = QBrush(Qt.green)
     painter.setBrush(brush)
     painter.drawEllipse(QRect(self.width()/2 - size/2, self.height()/2 - size/2, size, size))
     painter.end()
     #painter ellipse 2
     painter2 = QPainter()
     painter2.begin(pixmap)
     painter2.setRenderHint(QPainter.Antialiasing)
     pen2 = QPen(Qt.green)
     pen2.setStyle(Qt.DotLine)
     pen2.setWidth(3)
     painter2.setPen(pen2)
     painter2.drawEllipse(QRect(self.width()/2 - size/2, self.height()/2 - size/2, size, size))
     painter2.end()
     
     self.ellipseLabel.setPixmap(QPixmap(pixmap))
     self.lastSize = s
예제 #21
0
 def _paint(self, p: QPainter):
     self._paint_bg(p)
     self._paint_title(p)
     p.setPen(QPen(self.pen().brush(), 1))
     self._paint_ins(p)
     self._paint_outs(p)
     self._paint_content(p)
예제 #22
0
 def paintEvent(self, paintEvent):
     painter = QPainter(self)
     painter.setPen(QPen(Qt.white))
     painter.drawText(QPointF(14, self.height()-16), str(self.message))
     painter.setPen(QPen(QBrush(QColor(58, 93, 208)), 8))
     if self.progress > 0.0:
         painter.drawLine(0, self.height()-4, self.progress * self.width(), self.height()-4)
예제 #23
0
def decorate_welcome_icon(icon, background_color):
    """Return a `QIcon` with a circle shaped background.
    """
    welcome_icon = QIcon()
    sizes = [32, 48, 64, 80]
    background_color = NAMED_COLORS.get(background_color, background_color)
    background_color = QColor(background_color)
    grad = radial_gradient(background_color)
    for size in sizes:
        icon_pixmap = icon.pixmap(5 * size / 8, 5 * size / 8)
        icon_size = icon_pixmap.size()
        icon_rect = QRect(QPoint(0, 0), icon_size)

        pixmap = QPixmap(size, size)
        pixmap.fill(QColor(0, 0, 0, 0))
        p = QPainter(pixmap)
        p.setRenderHint(QPainter.Antialiasing, True)
        p.setBrush(QBrush(grad))
        p.setPen(Qt.NoPen)
        ellipse_rect = QRect(0, 0, size, size)
        p.drawEllipse(ellipse_rect)
        icon_rect.moveCenter(ellipse_rect.center())
        p.drawPixmap(icon_rect.topLeft(), icon_pixmap)
        p.end()

        welcome_icon.addPixmap(pixmap)

    return welcome_icon
예제 #24
0
 def paintEvent(self, event):
     """
     Overloads the paint event to support rendering of hints if there are
     no items in the tree.
     
     :param      event | <QPaintEvent>
     """
     super(XTextEdit, self).paintEvent(event)
     
     if self.document().isEmpty() and self.hint():
         text    = self.hint()
         rect    = self.rect()
         
         # modify the padding on the rect
         rect.setX(4)
         rect.setY(4)
         align = int(Qt.AlignLeft | Qt.AlignTop)
         
         # setup the coloring options
         clr = self.hintColor()
         
         # paint the hint
         painter = QPainter(self.viewport())
         painter.setPen(clr)
         painter.drawText(rect, align | Qt.TextWordWrap, text)
예제 #25
0
    def setNameAndBrush(self, sigma, color=Qt.black):
        self.sigma = sigma
        self.setText(
            decode_to_qstring("σ=%.1fpx" % self.sigma, "utf-8")
        )  # This file is encoded as utf-8, so this string should be decoded as such.
        total_window = 1 + 2 * int(self.sigma * self.window_size + 0.5)
        self.setToolTip("sigma = {:.1f} pixels, window diameter = {:.1f}".format(self.sigma, total_window))
        font = QFont()
        font.setPointSize(10)
        font.setBold(True)
        self.setFont(font)
        self.setForeground(color)

        pixmap = QPixmap(self.pixmapSize)
        pixmap.fill(Qt.transparent)
        painter = QPainter()
        painter.begin(pixmap)
        painter.setRenderHint(QPainter.Antialiasing, True)
        painter.setPen(color)
        brush = QBrush(color)
        painter.setBrush(brush)
        painter.drawEllipse(
            QRect(
                self.pixmapSize.width() / 2 - self.brushSize / 2,
                self.pixmapSize.height() / 2 - self.brushSize / 2,
                self.brushSize,
                self.brushSize,
            )
        )
        painter.end()
        self.setIcon(QIcon(pixmap))
        self.setTextAlignment(Qt.AlignVCenter)
예제 #26
0
 def __write(self, text, font, pen):
     width = QFontMetrics(font).width(text+' ')
     painter = QPainter(self)
     painter.setFont(font)
     painter.setPen(pen)
     painter.drawText(self.spaceLeft, Qt.AlignBottom, text)
     self.spaceLeft.setLeft(self.spaceLeft.left() + width ) # move the left edge to the end of what we just painted.
예제 #27
0
    def paintEvent(self, ev):
        color = self.palette().color(QPalette.Highlight)
        painter = QPainter(self)

        # Filled rectangle.
        painter.setClipRect(self.rect())
        color.setAlpha(50)
        painter.fillRect(self.rect().adjusted(2,2,-2,-2), color)

        # Thin rectangle outside.
        color.setAlpha(150)
        painter.setPen(color)
        painter.drawRect(self.rect().adjusted(0,0,-1,-1))

        # Pseudo-handles at the corners and sides
        color.setAlpha(100)
        pen = QPen(color)
        pen.setWidth(8)
        painter.setPen(pen)
        painter.setBackgroundMode(Qt.OpaqueMode)
        # Clip at 4 corners
        region = QRegion(QRect(0,0,20,20))
        region += QRect(self.rect().width()-20, 0, 20, 20)
        region += QRect(self.rect().width()-20, self.rect().height()-20, 20, 20)
        region += QRect(0, self.rect().height()-20, 20, 20)
        # Clip middles
        region += QRect(0, self.rect().height()/2-10, self.rect().width(), 20)
        region += QRect(self.rect().width()/2-10, 0, 20, self.rect().height())
        
        # Draw thicker rectangles, clipped at corners and sides.
        painter.setClipRegion(region)
        painter.drawRect(self.rect())
예제 #28
0
    def paintEvent(self, e):
        painter = QPainter(self)

        brush = QBrush(painter.brush())
        self.bgcolor.setAlpha(20)
        painter.setBrush(self.bgcolor)
        painter.drawRect(0, 0, self.width(), self.height())
        self.bgcolor.setAlpha(15)
        painter.setBrush(self.bgcolor)
        painter.drawRect(0, 20, self.width(), self.height()-40)
        painter.setBrush(brush)

        frame = self.clock.last_beat_frame
        x = self.x_for_frametime(frame)
        while x < self.width():
            x = self.x_for_frametime(frame)
            painter.drawLine(x, 0, x, 15)
            painter.drawLine(x, self.height(), x, self.height() - 15)
            #painter.drawText(QPoint(x+5, 13), str(frame))
            frame += self.clock.frames_per_beat()

        self.items = [i for i in self.items if i.endtime > self.frametime]
        for item in self.items:
            x = self.x_for_frametime(item.starttime)
            w = self.x_for_frametime(item.endtime) - x
            color = QColor(item.color)
            color.setAlpha(150)
            painter.setPen(color)
            pen = painter.pen()
            pen.setWidth(3)
            painter.setPen(pen)
            color.setAlpha(100)
            painter.setBrush(color)
            painter.drawRect(x, 0, w, self.height())
예제 #29
0
 def updateFilledCircle(self, s):
     size = s * self.zoom
     pixmap = QPixmap(self.width(), self.height())
     pixmap.fill(Qt.transparent)
     #painter filled ellipse
     p = QPalette()
     painter = QPainter()
     painter.begin(pixmap)
     painter.setRenderHint(QPainter.Antialiasing)
     brush = QBrush(p.link().color())
     painter.setBrush(brush)
     painter.setOpacity(0.4)
     painter.drawEllipse(QRect(self.width()/2 - size/2, self.height()/2 - size/2, size, size))
     painter.end()
     #painter ellipse 2
     painter2 = QPainter()
     painter2.begin(pixmap)
     painter2.setRenderHint(QPainter.Antialiasing)
     pen2 = QPen(Qt.green)
     pen2.setWidth(1)
     painter2.setPen(pen2)
     painter2.drawEllipse(QRect(self.width()/2 - size/2, self.height()/2 - size/2, size, size))
     painter2.end()
     
     self.ellipseLabel.setPixmap(QPixmap(pixmap))
     self.lastSize = s
예제 #30
0
    def __init__(self, parent, delegate):
        QWidget.__init__(self, parent)
        self.delegate = delegate
        self.emitted = False
        self.ui = Ui_AskVerdict()
        self.ui.setupUi(self)
        # build verdict icons
        if not AskVerdict.icons_cache:
            for text in VERDICTS:
                color = VERDICT_TO_ROW_COLORS.get(text[0])
                pixmap = QPixmap(16, 16)
                pixmap.fill(Qt.transparent)
                if color:
                    painter = QPainter(pixmap)
                    painter.setPen(Qt.black)
                    painter.setBrush(color)
                    painter.drawEllipse(0, 0, 15, 15)
                    painter.end()
                AskVerdict.icons_cache[text] = QIcon(pixmap)

        # set combo verdict
        for text in ('other...', 'skip', 'retry'):
            self.ui.comboVerdict.addItem(AskVerdict.icons_cache[text], text)
        model = self.ui.comboVerdict.model()
        model.itemFromIndex(model.index(0, 0)).setSelectable(False)

        self.ui.comboVerdict.activated.connect(self.on_dropdown_item_activated)

        self.ui.goodVerdict.clicked.connect(self.on_good_bad_button_clicked)
        self.ui.goodVerdict.setIcon(AskVerdict.icons_cache["good"])

        self.ui.badVerdict.clicked.connect(self.on_good_bad_button_clicked)
        self.ui.badVerdict.setIcon(AskVerdict.icons_cache["bad"])
예제 #31
0
    def setHistogram(self, values=None, bins=None, use_kde=False, histogram=None):
        """ Set background histogram (or density estimation, violin plot)

        The histogram of bins is calculated from values, optionally as a
        Gaussian KDE. If histogram is provided, its values are used directly
        and other parameters are ignored.
        """
        if (values is None or not len(values)) and histogram is None:
            self.setPixmap(None)
            return
        if histogram is not None:
            self._histogram = hist = histogram
        else:
            if bins is None:
                bins = min(100, max(10, len(values) // 20))
            if use_kde:
                hist = gaussian_kde(values,
                                    None if isinstance(use_kde, bool) else use_kde)(
                    np.linspace(np.min(values), np.max(values), bins))
            else:
                hist = np.histogram(values, bins)[0]
            self._histogram = hist = hist / hist.max()

        HEIGHT = self.rect().height() / 2
        OFFSET = HEIGHT * .3
        pixmap = QPixmap(QSize(len(hist), 2 * (HEIGHT + OFFSET)))  # +1 avoids right/bottom frame border shadow
        pixmap.fill(Qt.transparent)
        painter = QPainter(pixmap)
        painter.setPen(QPen(Qt.darkGray))
        for x, value in enumerate(hist):
            painter.drawLine(x, HEIGHT * (1 - value) + OFFSET,
                             x, HEIGHT * (1 + value) + OFFSET)

        if self.orientation() != Qt.Horizontal:
            pixmap = pixmap.transformed(QTransform().rotate(-90))

        self.setPixmap(pixmap)
예제 #32
0
        def paintEvent(self, event):

            painter = QPainter(self)
            painter.fillRect(event.rect(), self.numberBarColor)

            block = self.editor.firstVisibleBlock()

            # Iterate over all visible text blocks in the document.
            while block.isValid():
                blockNumber = block.blockNumber()
                block_top = self.editor.blockBoundingGeometry(
                    block).translated(self.editor.contentOffset()).top()

                # Check if the position of the block is out side of the visible area.
                if not block.isVisible() or block_top >= event.rect().bottom():
                    break

                # We want the line number for the selected line to be bold.
                if blockNumber == self.editor.textCursor().blockNumber():
                    self.font.setBold(True)
                    painter.setPen(QColor("#000000"))
                else:
                    self.font.setBold(False)
                    painter.setPen(QColor("#717171"))
                painter.setFont(self.font)

                # Draw the line number right justified at the position of the line.
                paint_rect = QRect(0, block_top, self.width(),
                                   self.editor.fontMetrics().height())
                painter.drawText(paint_rect, Qt.AlignRight,
                                 str(blockNumber + 1))

                block = block.next()

            painter.end()

            QWidget.paintEvent(self, event)
예제 #33
0
def hexagon_mask(image, hexa=False, **kwargs):
    """
    Appliquer un découpage du masque de l'image en hexagone arrondi

    :param image: image PIL
    :param hexa: False ou le rayon des arrondis de l'hexagone en pixels
    :return: Une image PIL dont le contour est un haxagone aux angles arrondis ou l'image originale
    """
    if hexa is not False:
        try:
            qimage = _pil_to_qt(image)
            # Créer une image de la même taille que l'originale
            newimage = _qt_canvas(image)
            painter = QPainter(newimage)
            painter.setRenderHint(QPainter.Antialiasing, True)
            # Dessiner un hexagone
            offset = hexa * 2.0
            width, height, bottom, top, t, l = qimage.width(
            ) - offset * 2, qimage.height(
            ) - offset * 2, 0.759, 0.241, offset, offset
            points = [
                l + width / 2.0, t + 0, l + width, t + height * top, l + width,
                t + height * bottom, l + width / 2.0, t + height, l + 0,
                t + height * bottom, l + 0, t + height * top
            ]
            brush = QBrush(qimage)
            pen = QPen(brush, offset * 2.0, cap=Qt.RoundCap, join=Qt.RoundJoin)
            pen.setColor(QColor(0, 0, 0, 0))
            painter.setBrush(brush)
            painter.setPen(pen)
            painter.drawPolygon(QPolygon(points))
            painter.end()
            return _qt_to_pil(newimage)
        except Exception:
            return image
    else:
        return image
예제 #34
0
    def set_item(self, item):
        """
        Set item to be displayed

        .. versionadded:: 0.6
        """
        self.item = item

        if item is not None:
            if is_ammunition(item):
                count = item.ammunition_data.count
            elif is_trap_bag(item):
                count = item.trap_data.count
            else:
                count = 1

            icon = self.surface_manager.get_icon(item.icon)

            if count != 1:
                image = icon.toImage()
                painter = QPainter(image)
                painter.setPen(Qt.white)
                font = QFont('Helvetica', 12, QFont.Bold, False)
                painter.setFont(font)
                painter.drawText(image.rect(), Qt.AlignBottom | Qt.AlignRight,
                                 str(count))
                icon = icon.fromImage(image)
                painter = None

            self.icon = icon
        else:
            if self.default_icon is None:
                self.icon = QPixmap(':transparent.png')
            else:
                self.icon = self.default_icon

        self.display.setPixmap(self.icon)
예제 #35
0
    def paintEvent(self, event):
        w = self.width()
        h = self.height()
        s = min(w, h)

        key = self._generateKey()
        pixmap = QPixmapCache.find(key)
        if not pixmap:
            pixmap = QPixmap(w, h)
            pixmap.fill(self, QPoint(0,
                                     0))  # Fill pixmap with widget background

            pixPainter = QPainter(pixmap)
            pixPainter.setRenderHint(QPainter.Antialiasing)

            # Offsets for centering
            ox = int(0.5 * (w - s))
            oy = int(0.5 * (h - s))

            insideColor = self._color
            if not self._value:
                insideColor = insideColor.darker(250)
            gradient = QRadialGradient(ox + 0.5 * s, oy + 0.5 * s, 0.5 * s)
            gradient.setColorAt(0.27, insideColor)
            gradient.setColorAt(0.6, insideColor.darker(120))
            gradient.setColorAt(1.0, insideColor.darker(160))
            pixPainter.setBrush(gradient)
            pixPainter.setPen(QPen(Qt.black, 2))
            pixPainter.drawEllipse(1 + ox, 1 + oy, s - 2, s - 2)
            pixPainter.end()
            QPixmapCache.insert(key, pixmap)

        p = QPainter()
        p.begin(self)
        p.drawPixmap(QPoint(0, 0), pixmap)
        p.end()
예제 #36
0
    def paintEvent(self, event):
        if self._isRunning:
            anglestep = 360. / self._steps
            fillsteps = self._fillsteps
            factor = min(self.width(), self.height()) / 16.
            bw = self._bw

            p = QPainter(self)
            p.setRenderHint(QPainter.Antialiasing, True)
            p.scale(factor, factor)
            p.setPen(Qt.NoPen)

            for i in range(self._steps):
                x1, y1 = self._coords[i]
                c = fillsteps[self._steps - 1 - i]
                a = anglestep * i
                p.setBrush(QBrush(QColor.fromRgbF(bw, bw, bw, c)))
                p.save()
                p.translate(x1 - 2, y1 - 1)
                p.translate(2, 1)
                p.rotate(a)
                p.translate(-2, -1)
                p.drawPath(self._path)
                p.restore()
예제 #37
0
 def paintEvent( self, event ):
     """
     Overloads the paint event to handle drawing the splitter lines.
     
     :param      event | <QPaintEvent>
     """
     lines = []
     count = 20
     
     # calculate the lines
     if ( self.orientation() == Qt.Vertical ):
         x = self._resizeGrip.pos().x()
         h = self.height()
         spacing = int(float(self._resizeGrip.width()) / count)
         
         for i in range(count):
             lines.append(QLine(x, 0, x, h))
             x += spacing
     else:
         y = self._resizeGrip.pos().y()
         w = self.width()
         spacing = int(float(self._resizeGrip.height()) / count)
         
         for i in range(count):
             lines.append(QLine(0, y, w, y))
             y += spacing
         
     # draw the lines
     painter = QPainter()
     painter.begin(self)
     
     pal = self.palette()
     painter.setPen(pal.color(pal.Window).darker(120))
     painter.drawLines(lines)
     
     painter.end()
예제 #38
0
 def paintEvent(self, event):
     super(Window, self).paintEvent(event)
     centerX = self.width() / 2
     centerY = self.height() / 2
     painter = QPainter(self)
     painter.setPen(QColor('black'))
     painter.setBrush(QBrush(QColor('black')))
     painter.drawLine(centerX, 0, centerX, self.height())
     painter.drawLine(0, centerY, self.width(), centerY)
     painter.setPen(QColor('blue'))
     painter.setBrush(QBrush(QColor('blue')))
     painter.drawEllipse(centerX - 5, centerY - 5, 10, 10)
     #        for value in self.data:
     #            points = self.get_point(value)
     #            for x, y in points:
     #                painter.drawEllipse(centerX + x, centerY + y, 1, 1)
     #        points = self.get_point(self.data[0])
     for i in range(1000):
         x = (i - 500)
         y = math.sin(x) * 100
         x2 = (i - 499)
         y2 = math.sin(x2) * 100
         painter.drawLine(centerX + x * 5, centerY - y, centerX + x2 * 5,
                          centerY - y2)
def _get_pos_widget(name, backgroundColor, foregroundColor):
    label = QLabel()
    label.setAttribute(Qt.WA_TransparentForMouseEvents, True)

    pixmap = QPixmap(25 * 10, 25 * 10)
    pixmap.fill(backgroundColor)
    painter = QPainter()
    painter.begin(pixmap)
    pen = QPen(foregroundColor)
    painter.setPen(pen)
    painter.setRenderHint(QPainter.Antialiasing)
    font = QFont()
    font.setBold(True)
    font.setPixelSize(25 * 10 - 30)
    path = QPainterPath()
    path.addText(QPointF(50, 25 * 10 - 50), font, name)
    brush = QBrush(foregroundColor)
    painter.setBrush(brush)
    painter.drawPath(path)
    painter.setFont(font)
    painter.end()
    pixmap = pixmap.scaled(QSize(20, 20), Qt.KeepAspectRatio,
                           Qt.SmoothTransformation)
    label.setPixmap(pixmap)

    spinbox = DelayedSpinBox(750)
    spinbox.setAlignment(Qt.AlignCenter)
    spinbox.setToolTip("{0} Spin Box".format(name))
    spinbox.setButtonSymbols(QAbstractSpinBox.NoButtons)
    spinbox.setMaximumHeight(20)
    font = spinbox.font()
    font.setPixelSize(14)
    spinbox.setFont(font)
    sheet = TEMPLATE.format(foregroundColor.name(), backgroundColor.name())
    spinbox.setStyleSheet(sheet)
    return label, spinbox
예제 #40
0
 def paintEvent(self, event):
     """Paint semi-transparent background,animated pattern,background text"""
     if not A11Y:
         p = QPainter(self)
         p.setRenderHint(QPainter.Antialiasing)
         p.setRenderHint(QPainter.TextAntialiasing)
         p.setRenderHint(QPainter.HighQualityAntialiasing)
         p.fillRect(event.rect(), Qt.transparent)
         # animated random dots background pattern
         for i in range(4096):
             x = randint(25, self.size().width() - 25)
             y = randint(25, self.size().height() - 25)
             # p.setPen(QPen(QColor(randint(9, 255), 255, 255), 1))
             p.drawPoint(x, y)
         p.setPen(QPen(Qt.white, 1))
         p.rotate(40)
         p.setFont(QFont('Ubuntu', 250))
         p.drawText(200, 99, "Nuitka")
         p.rotate(-40)
         p.setPen(Qt.NoPen)
         p.setBrush(QColor(0, 0, 0))
         p.setOpacity(0.8)
         p.drawRoundedRect(self.rect(), 9, 9)
         p.end()
예제 #41
0
    def line_number_area_paint_event(self, event):
        mypainter = QPainter(self.lineNumberArea)

        mypainter.fillRect(event.rect(), Qt.lightGray)

        block = self.firstVisibleBlock()
        block_number = block.blockNumber()
        top = self.blockBoundingGeometry(block).translated(
            self.contentOffset()).top()
        bottom = top + self.blockBoundingRect(block).height()

        # Just to make sure I use the right font
        height = self.fontMetrics().height()
        while block.isValid() and (top <= event.rect().bottom()):
            if block.isVisible() and (bottom >= event.rect().top()):
                number = str(block_number + 1)
                mypainter.setPen(Qt.black)
                mypainter.drawText(0, top, self.lineNumberArea.width(), height,
                                   Qt.AlignCenter, number)

            block = block.next()
            top = bottom
            bottom = top + self.blockBoundingRect(block).height()
            block_number += 1
예제 #42
0
    def paintEvent(self, event):
        """QLineEdit.paintEvent implementation.
        Draws prompt
        """
        QLineEdit.paintEvent(self, event)

        if self._promptText and not self.text() and self.isEnabled():
            option = QStyleOptionFrameV3()
            self.initStyleOption(option)

            left, top, right, bottom = self.getTextMargins()

            va = self.style().visualAlignment(self.layoutDirection(),
                                              self.alignment())
            rect = self.style().subElementRect(
                QStyle.SE_LineEditContents, option,
                self).adjusted(2, 0, 0, 0).adjusted(left, top, -right, -bottom)
            fm = QFontMetrics(self.font())
            text = fm.elidedText(self._promptText, Qt.ElideRight, rect.width())
            painter = QPainter(self)

            painter.setPen(self.palette().color(QPalette.Disabled,
                                                QPalette.Text))
            painter.drawText(rect, va, text)
예제 #43
0
    def setNameAndBrush(self, sigma, color=Qt.black):
        self.sigma = sigma
        self.setText(str(self.brushSize))
        font = QFont()
        font.setPointSize(10)
        font.setBold(True)
        self.setFont(font)
        self.setForeground(color)

        pixmap = QPixmap(self.pixmapSize)
        pixmap.fill(Qt.transparent)
        painter = QPainter()
        painter.begin(pixmap)
        painter.setRenderHint(QPainter.Antialiasing, True)
        painter.setPen(color)
        brush = QBrush(color)
        painter.setBrush(brush)
        painter.drawEllipse(
            QRect(self.pixmapSize.width() / 2 - self.brushSize / 2,
                  self.pixmapSize.height() / 2 - self.brushSize / 2,
                  self.brushSize, self.brushSize))
        painter.end()
        self.setIcon(QIcon(pixmap))
        self.setTextAlignment(Qt.AlignVCenter)
예제 #44
0
    def paintEvent(self, event):
        painter = QPainter(self)

        minSize = min(self.rect().width(), self.rect().height())
        myRect = QRect(self.rect().x(), self.rect().y(), minSize, minSize)

        painter.drawPixmap(myRect, self.backgroundPic,
                           self.backgroundPic.rect())

        pen = QPen()
        pen.setCapStyle(Qt.RoundCap)
        pen.setWidthF(4.0)
        pen.setColor(Qt.red)
        pen.setJoinStyle(Qt.RoundJoin)
        painter.setPen(pen)
        spacing = 30
        contentRect = myRect.adjusted(spacing, spacing, -spacing, -spacing)

        math_pi = 3.14159265358979323846
        degree = self.m_value - 90
        degree = degree * math_pi / 180
        radius = (contentRect.width() - spacing * 0.5) * 0.5
        vec = QPoint(radius * math.cos(degree), radius * math.sin(degree))
        painter.drawLine(contentRect.center(), contentRect.center() + vec)
예제 #45
0
파일: conf.py 프로젝트: Python3pkg/OASYS1
    def splash_screen():
        path = pkg_resources.resource_filename(
            __name__, "icons/oasys-splash-screen.png")
        pm = QPixmap(path)

        version = QCoreApplication.applicationVersion()
        size = 21 if len(version) < 5 else 16
        font = QFont("Helvetica")
        font.setPixelSize(size)
        font.setBold(True)
        font.setItalic(True)
        font.setLetterSpacing(QFont.AbsoluteSpacing, 2)
        metrics = QFontMetrics(font)
        br = metrics.boundingRect(version).adjusted(-5, 0, 5, 0)
        br.moveCenter(QPoint(436, 224))

        p = QPainter(pm)
        p.setRenderHint(QPainter.Antialiasing)
        p.setRenderHint(QPainter.TextAntialiasing)
        p.setFont(font)
        p.setPen(QColor("#231F20"))
        p.drawText(br, Qt.AlignCenter, version)
        p.end()
        return pm, QRect(88, 193, 200, 20)
예제 #46
0
    def paintEvent(self, ev):
        color = self.palette().color(QPalette.Highlight)
        painter = QPainter(self)

        # Filled rectangle.
        painter.setClipRect(self.rect())
        color.setAlpha(50)
        painter.fillRect(self.rect().adjusted(2, 2, -2, -2), color)

        # Thin rectangle outside.
        color.setAlpha(150)
        painter.setPen(color)
        painter.drawRect(self.rect().adjusted(0, 0, -1, -1))

        # Pseudo-handles at the corners and sides
        color.setAlpha(100)
        pen = QPen(color)
        pen.setWidth(8)
        painter.setPen(pen)
        painter.setBackgroundMode(Qt.OpaqueMode)
        # Clip at 4 corners
        region = QRegion(QRect(0, 0, 20, 20))
        region += QRect(self.rect().width() - 20, 0, 20, 20)
        region += QRect(self.rect().width() - 20,
                        self.rect().height() - 20, 20, 20)
        region += QRect(0, self.rect().height() - 20, 20, 20)
        # Clip middles
        region += QRect(0,
                        self.rect().height() / 2 - 10,
                        self.rect().width(), 20)
        region += QRect(self.rect().width() / 2 - 10, 0, 20,
                        self.rect().height())

        # Draw thicker rectangles, clipped at corners and sides.
        painter.setClipRegion(region)
        painter.drawRect(self.rect())
예제 #47
0
    def paintEvent(self, Event=None):
        p = QPainter(self)
        dx = 4

        W = self.width()
        H = self.height() - 5
        N = len(self.load_history)
        if N > W / dx:
            tail = N - W / dx
            N = W / dx
            self.load_history = self.load_history[tail:]

        assert len(self.load_history) == N

        for i in range(0, N - 1):
            val = self.load_history[N - i - 1]
            sat = 70 + val * (255 - 70) / 100
            color = QColor.fromHsv(self.hue, sat, 255)
            pen = QPen(color)
            pen.setWidth(dx - 1)
            p.setPen(pen)
            if val > 0:
                p.drawLine(W - i * dx - dx, H, W - i * dx - dx,
                           H - (H - 5) * val / 100)
예제 #48
0
    def paintEvent(self, event):
        spacing = 15
        contentRect = self.rect().adjusted(spacing, spacing, -spacing,
                                           -spacing)

        painter = QPainter(self)
        painter.setRenderHint(QPainter.Antialiasing)

        pen = QPen()
        pen.setCapStyle(Qt.RoundCap)
        pen.setWidthF(1.0 + self.width() / 15.0)
        pen.setColor(Qt.white)
        pen.setJoinStyle(Qt.RoundJoin)
        painter.setPen(pen)

        painter.drawArc(contentRect, (-45) * 16, (2 * 135) * 16)
        valueInPercent = (self.m_value - self.m_minimum) / (self.m_maximum -
                                                            self.m_minimum)
        math_pi = 3.14159265358979323846
        degree = (135 + 90) - valueInPercent * 2.0 * 135.0
        degree = degree * math_pi / 180.0
        radius = (contentRect.width() - spacing * 0.5) * 0.5
        vec = QPoint(radius * math.cos(degree), radius * -math.sin(degree))
        painter.drawLine(contentRect.center(), contentRect.center() + vec)
예제 #49
0
    def drawPatchQt(self, pos, turn, invert, patch_type, image, size,
                    foreColor, backColor, penwidth):  # pylint: disable=unused-argument
        """
        :param size: patch size
        """
        path = self.PATH_SET[patch_type]
        if not path:
            # blank patch
            invert = not invert
            path = [(0., 0.), (1., 0.), (1., 1.), (0., 1.), (0., 0.)]

        polygon = QPolygonF([QPointF(x * size, y * size) for x, y in path])

        rot = turn % 4
        rect = [
            QPointF(0., 0.),
            QPointF(size, 0.),
            QPointF(size, size),
            QPointF(0., size)
        ]
        rotation = [0, 90, 180, 270]

        nopen = QtGui.QPen(foreColor, Qt.NoPen)
        foreBrush = QtGui.QBrush(foreColor, Qt.SolidPattern)
        if penwidth > 0:
            pen_color = QtGui.QColor(255, 255, 255)
            pen = QtGui.QPen(pen_color, Qt.SolidPattern)
            pen.setWidth(penwidth)

        painter = QPainter()
        painter.begin(image)
        painter.setPen(nopen)

        painter.translate(pos[0] * size + penwidth / 2,
                          pos[1] * size + penwidth / 2)
        painter.translate(rect[rot])
        painter.rotate(rotation[rot])

        if invert:
            # subtract the actual polygon from a rectangle to invert it
            poly_rect = QPolygonF(rect)
            polygon = poly_rect.subtracted(polygon)
        painter.setBrush(foreBrush)
        if penwidth > 0:
            # draw the borders
            painter.setPen(pen)
            painter.drawPolygon(polygon, Qt.WindingFill)
        # draw the fill
        painter.setPen(nopen)
        painter.drawPolygon(polygon, Qt.WindingFill)

        painter.end()

        return image
예제 #50
0
    def paintEvent(self, event):
        realSize = min(self.width(), self.height())

        painter = QPainter()
        painter.begin(self)
        pen = QPen(Qt.black)
        pen.setWidth(1)
        painter.setPen(Qt.black)

        painter.setRenderHint(QPainter.Antialiasing)
        painter.translate(self.width() / 2, self.height() / 2)
        painter.scale(
            float(realSize) / self.scaledSize,
            float(realSize) / self.scaledSize)
        gradient = QRadialGradient(QPointF(-500, -500), 1500,
                                   QPointF(-500, -500))
        gradient.setColorAt(0, QColor(224, 224, 224))
        gradient.setColorAt(1, QColor(28, 28, 28))
        painter.setPen(pen)
        painter.setBrush(QBrush(gradient))
        painter.drawEllipse(QPointF(0, 0), 500, 500)

        gradient = QRadialGradient(QPointF(500, 500), 1500, QPointF(500, 500))
        gradient.setColorAt(0, QColor(224, 224, 224))
        gradient.setColorAt(1, QColor(28, 28, 28))
        painter.setPen(pen)
        painter.setBrush(QBrush(gradient))
        painter.drawEllipse(QPointF(0, 0), 450, 450)

        painter.setPen(pen)
        if (self.isChecked()):
            gradient = QRadialGradient(QPointF(-500, -500), 1500,
                                       QPointF(-500, -500))
            gradient.setColorAt(0, self._onColor1)
            gradient.setColorAt(1, self._onColor2)
        else:
            gradient = QRadialGradient(QPointF(500, 500), 1500,
                                       QPointF(500, 500))
            gradient.setColorAt(0, self._offColor1)
            gradient.setColorAt(1, self._offColor2)

        painter.setBrush(gradient)
        painter.drawEllipse(QPointF(0, 0), 400, 400)
        painter.end()
예제 #51
0
 def paintEvent(self, event):
     """
     Draw the QImage on screen.
     """
     textPosX,textPosY = 10,200
     painter = QPainter(self)
     painter.drawImage(painter.viewport(), self._image)
     innerFont = QFont()
     innerFont.setPointSize(12)
     painter.setFont(innerFont)
     painter.setPen(QColor(QtCore.Qt.white))
     painter.drawText(10,180,'Current Action:')
     painter.drawText(10,200,self._currentMovement)
     self.drawMoreText(painter,10,300,['Control Buttons:',
     'w,s - Walking Forwards/Backwards',
     'q,e - Walking Left/Right',
     'a,d - Turning Left/Right',
     'x - stopping',
     'Space - standing up',
     'Ctrl - crouch',
     'Escape,Enter - restMode, wakeUp',
     '1 - Grabbing small',
     '2 - Grabbing large',
     '3 - Grabbing Kuscheltier',
     '4 - Grabbing bottle'])
     self.drawMoreText(painter,self.width()-300-25,300,['Dialog Control:({})'.format(self._attitude),
     'u - Introduction',
     'i - Ask for object',
     'h - Object is Somat',
     'j - Object is Muesli',
     'k - Object is Bottle',
     'l - Object is Kuscheltier',
     'n - Wertstoff',
     'm - Altpapier', 
     'o - Ask for help',
     'z - Ask proband to repeat sentence',
     'p - Repeat task',
     '0(Null) - construct initial state',
     't - Goodbye',
     'b - thanks',
     '# - Start free Speech(PopUp)'])
     self.drawMoreText(painter,100,50,['Movement Speeds','Forward: {}'.format(self._currentSpeeds['Forward']),'Leftward: {}'.format(self._currentSpeeds['Leftward']),'CounterClockwise: {}'.format(self._currentSpeeds['CounterClockwise'])])
     pen = QPen()
     pen.setColor(QColor(QtCore.Qt.red))
     pen.setWidth(5)
     painter.setPen(pen)
     painter.drawEllipse(20,15,60,30)
     pen.setColor(QColor(QtCore.Qt.blue))
     painter.setPen(pen)
     painter.drawPolygon(self.rotatePolygon(arrowPolygon,math.degrees(self._motionProxy.getAngles('HeadYaw',True)[0]),[30,20]))
예제 #52
0
 def paintEvent(self, *args, **kwargs):
     painter = QPainter(self)
     painter.drawPixmap(0, 0, 12, self.WIDTH_BORDER_TOP, self.__pic_bg, 0,
                        0, 12, self.WIDTH_BORDER_TOP)
     painter.drawPixmap(
         self.WIDTH_BORDER_LEFT, 0,
         self.width() - self.WIDTH_BORDER_RIGHT - self.WIDTH_BORDER_LEFT,
         self.WIDTH_BORDER_TOP, self.__pic_bg, 12, 0, 1,
         self.WIDTH_BORDER_TOP)
     painter.drawPixmap(self.width() - self.WIDTH_BORDER_RIGHT, 0,
                        self.__pic_bg, 13, 0, 12, self.WIDTH_BORDER_TOP)
     painter.drawPixmap(0,
                        self.height() - self.WIDTH_BORDER_BOTTOM,
                        self.__pic_bg, 0, 90, 12, 14)
     painter.drawPixmap(
         0, self.WIDTH_BORDER_TOP, self.WIDTH_BORDER_LEFT,
         self.height() - self.WIDTH_BORDER_BOTTOM - self.WIDTH_BORDER_TOP,
         self.__pic_bg, 0, 89, 12, 1)
     painter.drawPixmap(
         self.width() - self.WIDTH_BORDER_RIGHT, self.WIDTH_BORDER_TOP,
         self.WIDTH_BORDER_LEFT,
         self.height() - self.WIDTH_BORDER_BOTTOM - self.WIDTH_BORDER_TOP,
         self.__pic_bg, 13, 89, 12, 1)
     painter.drawPixmap(
         self.WIDTH_BORDER_LEFT,
         self.height() - self.WIDTH_BORDER_BOTTOM,
         self.width() - self.WIDTH_BORDER_RIGHT - self.WIDTH_BORDER_LEFT,
         self.WIDTH_BORDER_BOTTOM, self.__pic_bg, 12, 90, 1, 14)
     painter.drawPixmap(self.width() - self.WIDTH_BORDER_RIGHT,
                        self.height() - self.WIDTH_BORDER_BOTTOM,
                        self.__pic_bg, 13, 90, 12, 14)
     painter.fillRect(
         self.WIDTH_BORDER_LEFT - 4, self.WIDTH_BORDER_TOP,
         self.width() - self.WIDTH_BORDER_LEFT - self.WIDTH_BORDER_RIGHT +
         8,
         self.height() - self.WIDTH_BORDER_BOTTOM - self.WIDTH_BORDER_TOP,
         QBrush(QColor(255, 255, 255)))
     painter.setFont(QFont('Microsoft Yahei', 8, QFont.Bold))
     painter.setPen(QColor(250, 250, 250, 220))
     painter.drawText(1, 5, self.width(), 27,
                      Qt.AlignHCenter | Qt.AlignVCenter, self.windowTitle())
     painter.setPen(QColor(50, 50, 50, 255))
     painter.drawText(0, 4, self.width(), 27,
                      Qt.AlignHCenter | Qt.AlignVCenter, self.windowTitle())
     painter.setPen(QColor(142, 142, 142, 255))
     if self.width() > 380:
         painter.drawLine(self.WIDTH_FRAME_LEFT + self.OFFSET_BORDER_LEFT,
                          self.OFFSET_BORDER_TOP + 22,
                          self.WIDTH_FRAME_LEFT + self.OFFSET_BORDER_LEFT,
                          self.height() - self.OFFSET_BORDER_BOTTOM - 1)
예제 #53
0
    def paintEvent(self, event):
        p = QPainter(self)
        p.fillRect(event.rect(), Qt.white)
        start = self.m_offset / self.m_height
        y = start * self.m_height - self.m_offset
        if self.m_offset <= 0:
            start = 0
            y = -self.m_offset

        end = start + self.height() / self.m_height + 1
        if end > len(self.m_colorNames) - 1:
            end = len(self.m_colorNames) - 1
        for i in range(start, end):

            p.setBrush(Qt.NoBrush)
            p.setPen(Qt.black)
            if i == self.m_highlight:
                p.fillRect(0, y, self.width(), self.m_height,
                           QColor(0, 64, 128))
                p.setPen(Qt.white)

            if i == self.m_selected:
                p.fillRect(0, y, self.width(), self.m_height,
                           QColor(0, 128, 240))
                p.setPen(Qt.white)

            p.drawText(self.m_height + 2, y, self.width(), self.m_height,
                       Qt.AlignVCenter, self.m_colorNames[i])

            p.setPen(Qt.NoPen)
            p.setBrush(QBrush(self.m_firstColor[i]))
            p.drawRect(1, y + 1, self.m_height - 2, self.m_height - 2)
            p.setBrush(QBrush(self.m_secondColor[i]))
            p.drawRect(5, y + 5, self.m_height - 11, self.m_height - 11)

            y += self.m_height

        p.end()
예제 #54
0
    def paintEvent(self, e: QPaintEvent):
        if not e.isAccepted():
            return
        p = QPainter(self)
        p.setRenderHint(QPainter.Antialiasing)
        p.setPen(QColor(0, 0, 0, 0))
        p.setBrush(QColor(55, 50, 47))
        p.drawRect(0, 0, 11, self.height())

        if self.__drag:
            p.setBrush(QColor(255, 255, 255, 180))
        else:
            p.setBrush(QColor(0, 0, 0, 180))
        p.setPen(QPen(QColor(255, 255, 255), 0.5))
        p.drawRoundedRect(1, 10, 20, 20, 2, 2)
        p.setBrush(QColor(205, 205, 205, 180))
        p.drawEllipse(4, 18, 4, 4)

        p.setBrush(self.palette().color(self.backgroundRole()))
        p.setPen(QColor(0, 0, 0, 0))
        p.drawRect(10, 0, self.width() - 10, self.height())
        p.setPen(QColor(0, 0, 0))
        p.drawLine(10, 0, 10, self.height())
예제 #55
0
 def _paint_bg(self, p: QPainter):
     pen = Block.selected_pen if self.__selected else Block.border_pen
     p.setRenderHint(QPainter.Antialiasing, True)
     p.setPen(pen)
     p.setBrush(self.bg())
     p.drawRoundedRect(Block.padding, Block.padding, self.width() - 2 * Block.padding,
                       self.height() - 2 * Block.padding, 8, 8)
     p.setBrush(self.title_bg())
     p.drawRoundedRect(Block.padding, Block.padding, self.width() - 2 * Block.padding, 35 + Block.padding, 8, 8)
     p.setBrush(self.bg())
     p.setPen(QColor(0, 0, 0, 0))
     p.drawRect(1 + Block.padding, 35 + Block.padding, self.width() - 2 - 2 * Block.padding, 10)
     p.setPen(pen)
     if self._resizable:
         p.setBrush(pen.brush())
         p.drawPath(self.__corner_path.translated(self.width(), self.height()))
예제 #56
0
    def paintEvent(self, e):
        qp = QPainter()
        qp.begin(self)

        if self.step == 'waiting_to_start':
            qp.setPen(QPen(Qt.red, 20, Qt.SolidLine))
            qp.setFont(QFont('Decorative', 20))

        if self.step == 'calibration_started':
            qp.setPen(QPen(Qt.red, 35, Qt.SolidLine))
            qp.drawEllipse(self.x, self.y, 40, 40)

        if self.step == 'show_gaze':
            qp.setPen(QPen(Qt.red, 10, Qt.SolidLine))
            qp.drawEllipse(self.x, self.y, 10, 10)

        qp.end()
예제 #57
0
    def paintEvent(self, ev):
        rect = ev.rect()
        s = self._square
        rows = range(rect.top() // s, rect.bottom() // s + 1)
        cols = range(rect.left() // s, rect.right() // s + 1)

        painter = QPainter(self)
        painter.setPen(QPen(self.palette().color(QPalette.Window)))
        painter.setFont(self._font)
        metrics = QFontMetrics(self._font)

        # draw characters on white tiles
        tile = self.palette().color(QPalette.Base)
        selected_tile = self.palette().color(QPalette.Highlight)
        selected_tile.setAlpha(96)
        selected_box = self.palette().color(QPalette.Highlight)

        text_pen = QPen(self.palette().text())
        disabled_pen = QPen(self.palette().color(QPalette.Disabled,
                                                 QPalette.Text))
        selection_pen = QPen(selected_box)
        for row in rows:
            for col in cols:
                char = row * self._column_count + col + self._range[0]
                if char > self._range[1]:
                    break
                printable = self.isprint(char)
                painter.setClipRect(col * s, row * s, s, s)
                if char == self._selected:
                    painter.fillRect(col * s + 1, row * s + 1, s - 2, s - 2,
                                     selected_tile)
                    painter.setPen(selection_pen)
                    painter.drawRect(col * s, row * s, s - 1, s - 1)
                elif printable:
                    painter.fillRect(col * s + 1, row * s + 1, s - 2, s - 2,
                                     tile)
                painter.setPen(text_pen if printable else disabled_pen)
                t = chr(char)
                x = col * s + s // 2 - metrics.width(t) // 2
                y = row * s + 4 + metrics.ascent()
                painter.drawText(x, y, t)
            else:
                continue
            break
예제 #58
0
 def combineTiles(self):
     global radar1
     ii = QImage(self.tilesWidth * 256, self.tilesHeight * 256,
                 QImage.Format_ARGB32)
     painter = QPainter()
     painter.begin(ii)
     painter.setPen(QColor(255, 255, 255, 255))
     painter.setFont(QFont("Arial", 10))
     i = 0
     xo = self.cornerTiles["NW"]["X"]
     xo = int((int(xo) - xo) * 256)
     yo = self.cornerTiles["NW"]["Y"]
     yo = int((int(yo) - yo) * 256)
     for y in range(0, self.totalHeight, 256):
         for x in range(0, self.totalWidth, 256):
             if self.tileQimages[i].format() == 5:
                 painter.drawImage(x, y, self.tileQimages[i])
             # painter.drawRect(x, y, 255, 255)
             # painter.drawText(x+3, y+12, self.tiletails[i])
             i += 1
     painter.end()
     painter = None
     self.tileQimages = []
     ii2 = ii.copy(-xo, -yo, self.rect.width(), self.rect.height())
     ii = None
     painter2 = QPainter()
     painter2.begin(ii2)
     timestamp = "{0:%H:%M} rainvewer.com".format(
         datetime.datetime.fromtimestamp(self.getTime))
     painter2.setPen(QColor(63, 63, 63, 255))
     painter2.setFont(QFont("Arial", 8))
     painter2.setRenderHint(QPainter.TextAntialiasing)
     painter2.drawText(3 - 1, 12 - 1, timestamp)
     painter2.drawText(3 + 2, 12 + 1, timestamp)
     painter2.setPen(QColor(255, 255, 255, 255))
     painter2.drawText(3, 12, timestamp)
     painter2.drawText(3 + 1, 12, timestamp)
     painter2.end()
     painter2 = None
     ii3 = QPixmap(ii2)
     ii2 = None
     self.frameImages.append({"time": self.getTime, "image": ii3})
     ii3 = None
 def paintEvent(self, event):
     if not self.resources:
         return
     paint = QPainter(self)
     for e in self.resources.edges:
         if e == self.selectedEdge:
             paint.setPen(self.colors["selected"])
         else:
             paint.setPen(self.colors["line"])
         self.drawArrow(paint, self.vertices[e.e1].x() + self.size / 2,
                        self.vertices[e.e1].y() + self.size / 2,
                        self.vertices[e.e2].x() + self.size / 2,
                        self.vertices[e.e2].y() + self.size / 2)
     for v in self.vertices.keys():
         if isinstance(v, Computer):
             if self.selectedVertex != self.vertices[v]:
                 paint.drawImage(self.vertices[v], self.computericon)
             else:
                 paint.drawImage(self.vertices[v],
                                 self.computerselectedicon)
         elif isinstance(v, Storage):
             if self.selectedVertex != self.vertices[v]:
                 paint.drawImage(self.vertices[v], self.storageicon)
             else:
                 paint.drawImage(self.vertices[v], self.storageselectedicon)
         elif isinstance(v, Router):
             if self.selectedVertex != self.vertices[v]:
                 paint.drawImage(self.vertices[v], self.routericon)
             else:
                 paint.drawImage(self.vertices[v], self.routerselectedicon)
     paint.setPen(self.colors["line"])
     if self.edgeDraw:
         self.drawArrow(
             paint, self.curEdge[0].x() + self.size / 2,
             self.curEdge[0].y() + self.size / 2,
             QCursor.pos().x() -
             self.mapToGlobal(self.geometry().topLeft()).x(),
             QCursor.pos().y() -
             self.mapToGlobal(self.geometry().topLeft()).y())
     paint.end()
예제 #60
0
    def image(self):
        width = (self.xmax - self.xmin + 1) * self.TILE_SIZE
        height = (self.ymax - self.ymin + 1) * self.TILE_SIZE

        image = QImage(width, height, QImage.Format_ARGB32_Premultiplied)
        image.fill(Qt.transparent)
        p = QPainter(image)

        for tile in self.tiles.values():
            if not tile.data:
                continue

            x = tile.x - self.xmin
            y = tile.y - self.ymin
            rect = QRect(x * self.TILE_SIZE, y * self.TILE_SIZE,
                         self.TILE_SIZE, self.TILE_SIZE)

            timg = QImage()
            res = timg.loadFromData(tile.data)
            if res:
                p.drawImage(rect, timg)

            if debug_mode:
                p.setPen(Qt.black)
                p.drawText(
                    rect,
                    Qt.AlignBottom | Qt.AlignRight,
                    # "x: %s, y:%s\nz: %s, data: %s" % (x, y, tile.zoom, tile.data.size())
                    "z: %s, data: %s" % (tile.zoom, tile.data.size()))
                if not res:
                    p.setPen(Qt.darkRed)
                    p.drawText(rect, Qt.AlignCenter, "Bad tile")

                p.setPen(Qt.black)
                p.drawRect(rect)

        return image