当前位置: 首页>>代码示例>>Python>>正文


Python QtGui.QPainter类代码示例

本文整理汇总了Python中PySide.QtGui.QPainter的典型用法代码示例。如果您正苦于以下问题:Python QPainter类的具体用法?Python QPainter怎么用?Python QPainter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了QPainter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: paintEvent

	def paintEvent(self, painteevent):
		painter = QPainter(self)

		painter.setRenderHint(QPainter.Antialiasing)

		for obj in self.objects:
			obj.paint(painter)
开发者ID:omartinak,项目名称:tests,代码行数:7,代码来源:main_window.py

示例2: paintEvent

    def paintEvent(self, e):
        'Custom Paint Event'
        p = QPainter(self)
        
        opt = QStyleOptionFrameV3()
        opt.initFrom(self)
        opt.rect = self.contentsRect()
        opt.lineWidth = self.style().pixelMetric(QStyle.PM_DefaultFrameWidth, opt, self)
        opt.midLineWidth = 0
        opt.state = opt.state | QStyle.State_Sunken
        
        if self._active:
            opt.state = opt.state | QStyle.State_HasFocus
        else:
            opt.state = opt.state & ~QStyle.State_HasFocus;
        
        self.style().drawPrimitive(QStyle.PE_PanelLineEdit, opt, p)

        y = (opt.rect.height() - self._star.height()) / 2 
        width = self._star.width()
        
        for i in range(0, 5):
            x = i*(width + 1) + opt.lineWidth
            
            if self._rating >= i+0.5:
                p.drawImage(x, y, self._star if not self._active else self._blue)
            else:
                p.drawImage(x, y, self._dot)
开发者ID:asymworks,项目名称:python-divelog,代码行数:28,代码来源:controls.py

示例3: set_clipboard_image

    def set_clipboard_image(self):
        """Export the formatted output to an image and store it in the
        clipboard.

        The image stored in the clipboard is a PNG file with alpha
        transparency.

        """
        div = self.view.page().mainFrame().findFirstElement('.output')
        images = {}
        for background in (Qt.transparent, Qt.white):
            image = QImage(div.geometry().size(),
                           QImage.Format_ARGB32_Premultiplied)
            image.fill(background)
            painter = QPainter(image)
            div.render(painter)
            painter.end()
            images[background] = image

        # Windows needs this buffer hack to get alpha transparency in
        # the copied PNG.
        buffer_ = QBuffer()
        buffer_.open(QIODevice.WriteOnly)
        images[Qt.transparent].save(buffer_, 'PNG')
        buffer_.close()
        data = QMimeData()
        data.setData('PNG', buffer_.data())
        data.setImageData(images[Qt.white])
        QApplication.clipboard().setMimeData(data)
开发者ID:spamalot,项目名称:quichem,代码行数:29,代码来源:pyside.py

示例4: paintEvent

 def paintEvent(self, pe):
   painter = QPainter(self) 
   if self._fill:
     scaled_pixmap = self._image_pixmap.scaled(self.size(), Qt.IgnoreAspectRatio)
     painter.drawPixmap(0, 0, scaled_pixmap)
   else:
     painter.drawPixmap(0, 0, self._image_pixmap)
开发者ID:github-account-because-they-want-it,项目名称:VisualScrape,代码行数:7,代码来源:support.py

示例5: SetImageTransparency

def SetImageTransparency(image, transparencyPercentage):
    """ Set the Image Transparency to the value provided """
    alpha = QImage(image)
    painter = QPainter(alpha)
    alphaValue = int(transparencyPercentage*255/100)
    painter.fillRect(alpha.rect(), QColor(alphaValue, alphaValue, alphaValue))
    painter.end()
    image.setAlphaChannel(alpha)
开发者ID:cloew,项目名称:PyMine,代码行数:8,代码来源:image_loader.py

示例6: paint

 def paint(self, painter, option, widget=None):
     painter_inverted = QPainter()
     brect= QGraphicsProxyWidget.boundingRect(self)
     invertedColor = QImage(brect.width(),brect.height(),QImage.Format_RGB32)
     painter_inverted.begin(invertedColor)
     QGraphicsProxyWidget.paint(self,painter_inverted, option, widget)
     painter_inverted.end()
     painter.drawImage(0,0,invertedColor.rgbSwapped())
开发者ID:coderakki,项目名称:Media-player,代码行数:8,代码来源:try.py

示例7: resizeImage

    def resizeImage(self, image, newSize):
        if image.size() == newSize:
            return
        newImage = QImage(newSize, QImage.Format_RGB32)
        newImage.fill(qRgb(255, 255, 255))
        painter = QPainter(newImage)
        painter.drawImage(QtCore.QPoint(0, 0), image)

        self.image = newImage
开发者ID:pouzzler,项目名称:IED-Logic-Simulator,代码行数:9,代码来源:circuitdrawing.py

示例8: _update_cursor

 def _update_cursor(self):
     x = self.diameter
     w, h = x, x
     pixmap = QPixmap(w, h)
     pixmap.fill(Qt.transparent)
     p = QPainter(pixmap)
     p.drawPoints(self._points)
     p.end()
     self._cursor_pixmap = pixmap.createMaskFromColor(Qt.transparent)
开发者ID:jthacker,项目名称:arrview,代码行数:9,代码来源:paintbrush.py

示例9: paintEvent

 def paintEvent(self, pe):
   if self._mouse_over:
     icon = self._hover_icon
   else:
     icon = self._normal_icon
   painter = QPainter(self)
   pixmap = QPixmap(icon)
   pixmap = pixmap.scaled(self.size(), Qt.IgnoreAspectRatio)
   painter.drawPixmap(0, 0, pixmap)
开发者ID:github-account-because-they-want-it,项目名称:VisualScrape,代码行数:9,代码来源:common.py

示例10: capture

    def capture(self, filename):
        image = QImage(self._view.page().currentFrame().contentsSize(), QImage.Format_ARGB32)

        painter = QPainter(image)

        self._view.page().currentFrame().render(painter)
        painter.end()

        image.save(filename)
开发者ID:halimath,项目名称:recap,代码行数:9,代码来源:browser.py

示例11: paintEvent

	def paintEvent(self, event):
		painter = QPainter()

		painter.begin(self)

		self.theme.render(painter, "kdiamond-" + self.color)
		if self.selected:
			self.theme.render(painter, "kdiamond-selection")

		painter.end()
开发者ID:omartinak,项目名称:flow,代码行数:10,代码来源:diamond.py

示例12: paintEvent

 def paintEvent(self, pe):
   super(ProgressLineEdit, self).paintEvent(pe)
   painter = QPainter(self)
   painter.setOpacity(self.property("_progress_opacity"))
   sopb = QStyleOptionProgressBarV2()
   sopb.minimum = 0
   sopb.maximum = 100
   sopb.progress = self._progress
   sopb.initFrom(self)
   self.style().drawControl(QStyle.CE_ProgressBarContents, sopb, painter, self)
开发者ID:github-account-because-they-want-it,项目名称:VisualScrape,代码行数:10,代码来源:ui_common.py

示例13: paintEvent

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

        :param `event`: A `QPaintEvent`_ to be processed.
        """
        painter = QPainter(self)
        painter.drawPixmap(0, 0, self.pixmap)
        if self.parent.lightswitch.isOn: # Turn the light on.
            painter.drawImage(self.size().width() - 113, 1, self.lightOnImg)
开发者ID:Drahflow,项目名称:Embroidermodder,代码行数:10,代码来源:tipoftheday_dialog.py

示例14: paint

    def paint(self, canvas, is_secondary_color=False, additional_flag=False):
        pen = QPen()
        pen.setWidth(self.data_singleton.pen_size)
        pen.setStyle(Qt.SolidLine)
        pen.setCapStyle(Qt.RoundCap)
        pen.setJoinStyle(Qt.RoundJoin)

        if is_secondary_color:
            pen.setBrush(self.data_singleton.secondary_color)
        else:
            pen.setBrush(self.data_singleton.primary_color)

        painter = QPainter(canvas.image)
        painter.setPen(pen)

        if self._start_point != self._end_point:
            painter.drawLine(self._start_point, self._end_point)

        if self._start_point == self._end_point:
            painter.drawPoint(self._start_point)

        painter.end()

        canvas.edited = True
        canvas.update()
开发者ID:gil9red,项目名称:fake-painter,代码行数:25,代码来源:pencilinstrument.py

示例15: paintEvent

 def paintEvent(self, e):
     ''' overwrite paintEvent in order to also redraw points (indicating
     electrode positions) and their link to added plots
     
     this is necessary to get smooth animation if plots are dragged around
     '''
     super(DragWindow, self).paintEvent(e)
     qp = QPainter()
     qp.begin(self)
     self.drawPoints(qp)
     qp.end()
开发者ID:Yakisoba007,项目名称:PyTrigno,代码行数:11,代码来源:plotter.py


注:本文中的PySide.QtGui.QPainter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。