• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python QtGui.QPainter类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: paintEvent

 def paintEvent(self, event):
     painter = QPainter(self)
     painter.setClipRegion(event.region())
     opt = QStyleOption()
     opt.initFrom(self)
     self.style().drawPrimitive(QStyle.PE_Widget, opt, painter, self)
     self.draw(painter)
开发者ID:petebachant,项目名称:python-qwt,代码行数:7,代码来源:scale_widget.py


示例2: fillPixmap

    def fillPixmap(self, widget, pixmap, offset=None):
        """
        Fill a pixmap with the content of a widget

        In Qt >= 5.0 `QPixmap.fill()` is a nop, in Qt 4.x it is buggy
        for backgrounds with gradients. Thus `fillPixmap()` offers 
        an alternative implementation.
        
        :param QWidget widget: Widget
        :param QPixmap pixmap: Pixmap to be filled
        :param QPoint offset: Offset
        
        .. seealso::
        
            :py:meth:`QPixmap.fill()`
        """
        if offset is None:
            offset = QPoint()
        rect = QRect(offset, pixmap.size())
        painter = QPainter(pixmap)
        painter.translate(-offset)
        autoFillBrush = widget.palette().brush(widget.backgroundRole())
        if not (widget.autoFillBackground() and autoFillBrush.isOpaque()):
            bg = widget.palette().brush(QPalette.Window)
            qwtFillRect(widget, painter, rect, bg)
        if widget.autoFillBackground():
            qwtFillRect(widget, painter, rect, autoFillBrush)
        if widget.testAttribute(Qt.WA_StyledBackground):
            painter.setClipRegion(rect)
            opt = QStyleOption()
            opt.initFrom(widget)
            widget.style().drawPrimitive(QStyle.PE_Widget, opt,
                                         painter, widget)
开发者ID:gyenney,项目名称:Tools,代码行数:33,代码来源:painter.py


示例3: toImage

 def toImage(self, *args):
     if len(args) == 0:
         if self.isNull():
             return QImage()
         sz = self.defaultSize()
         w = np.ceil(sz.width())
         h = np.ceil(sz.height())
         image = QImage(w, h, QImage.Format_ARGB32)
         image.fill(0)
         r = QRect(0, 0, sz.width(), sz.height())
         painter = QPainter(image)
         self.render(painter, r, Qt.KeepAspectRatio)
         painter.end()
         return image
     elif len(args) in (1, 2):
         size = args[0]
         aspectRatioMode = Qt.IgnoreAspectRatio
         if len(args) == 2:
             aspectRatioMode = args[-1]
         image = QImage(size, QImage.Format_ARGB32_Premultiplied)
         image.fill(0)
         r = QRect(0, 0, size.width(), size.height())
         painter = QPainter(image)
         self.render(painter, r, aspectRatioMode)
         return image
开发者ID:petebachant,项目名称:python-qwt,代码行数:25,代码来源:graphic.py


示例4: legendIcon

 def legendIcon(self, index, size):
     """
     :param int index: Index of the legend entry (ignored as there is only one)
     :param QSizeF size: Icon size
     :return: Icon representing the marker on the legend
     
     .. seealso::
     
         :py:meth:`qwt.plot.QwtPlotItem.setLegendIconSize()`,
         :py:meth:`qwt.plot.QwtPlotItem.legendData()`
     """
     if size.isEmpty():
         return QwtGraphic()
     icon = QwtGraphic()
     icon.setDefaultSize(size)
     icon.setRenderHint(QwtGraphic.RenderPensUnscaled, True)
     painter = QPainter(icon)
     painter.setRenderHint(QPainter.Antialiasing,
                       self.testRenderHint(QwtPlotItem.RenderAntialiased))
     if self.__data.style != QwtPlotMarker.NoLine:
         painter.setPen(self.__data.pen)
         if self.__data.style in (QwtPlotMarker.HLine, QwtPlotMarker.Cross):
             y = .5*size.height()
             QwtPainter.drawLine(painter, 0., y, size.width(), y)
         if self.__data.style in (QwtPlotMarker.VLine, QwtPlotMarker.Cross):
             x = .5*size.width()
             QwtPainter.drawLine(painter, x, 0., x, size.height())
     if self.__data.symbol:
         r = QRect(0, 0, size.width(), size.height())
         self.__data.symbol.drawSymbol(painter, r)
     return icon
开发者ID:gyenney,项目名称:Tools,代码行数:31,代码来源:plot_marker.py


示例5: borderPath

    def borderPath(self, rect):
        """
        Calculate the painter path for a styled or rounded border

        When the canvas has no styled background or rounded borders
        the painter path is empty.

        :param QRect rect: Bounding rectangle of the canvas
        :return: Painter path, that can be used for clipping
        """
        if self.testAttribute(Qt.WA_StyledBackground):
            recorder = QwtStyleSheetRecorder(rect.size())
            painter = QPainter(recorder)
            opt = QStyleOption()
            opt.initFrom(self)
            opt.rect = rect
            self.style().drawPrimitive(QStyle.PE_Widget, opt, painter, self)
            painter.end()
            if not recorder.background.path.isEmpty():
                return recorder.background.path
            if not recorder.border.rectList.isEmpty():
                return qwtCombinePathList(rect, recorder.border.pathlist)
        elif self.__data.borderRadius > 0.:
            fw2 = self.frameWidth()*.5
            r = QRectF(rect).adjusted(fw2, fw2, -fw2, -fw2)
            path = QPainterPath()
            path.addRoundedRect(r, self.__data.borderRadius,
                                self.__data.borderRadius)
            return path
        return QPainterPath()
开发者ID:berrosse,项目名称:PythonQwt,代码行数:30,代码来源:plot_canvas.py


示例6: defaultIcon

 def defaultIcon(brush, size):
     icon = QwtGraphic()
     if not size.isEmpty():
         icon.setDefaultSize(size)
         r = QRectF(0, 0, size.width(), size.height())
         painter = QPainter(icon)
         painter.fillRect(r, brush)
     return icon
开发者ID:petebachant,项目名称:python-qwt,代码行数:8,代码来源:plot.py


示例7: toImage

    def toImage(self, *args):
        """
        .. py:method:: toImage()
        
            Convert the graphic to a `QImage`

            All pixels of the image get initialized by 0 ( transparent )
            before the graphic is scaled and rendered on it.

            The format of the image is `QImage.Format_ARGB32_Premultiplied`.
            
            The size of the image is the default size ( ceiled to integers )
            of the graphic.

            :return: The graphic as image in default size

        .. py:method:: toImage(size, [aspectRatioMode=Qt.IgnoreAspectRatio])
        
            Convert the graphic to a `QImage`

            All pixels of the image get initialized by 0 ( transparent )
            before the graphic is scaled and rendered on it.

            The format of the image is `QImage.Format_ARGB32_Premultiplied`.
            
            :param QSize size: Size of the image
            :param `Qt.AspectRatioMode` aspectRatioMode: Aspect ratio how to scale the graphic
            :return: The graphic as image

        .. seealso::
        
            :py:meth:`toPixmap()`, :py:meth:`render()`
        """
        if len(args) == 0:
            if self.isNull():
                return QImage()
            sz = self.defaultSize()
            w = np.ceil(sz.width())
            h = np.ceil(sz.height())
            image = QImage(w, h, QImage.Format_ARGB32)
            image.fill(0)
            r = QRect(0, 0, sz.width(), sz.height())
            painter = QPainter(image)
            self.render(painter, r, Qt.KeepAspectRatio)
            painter.end()
            return image
        elif len(args) in (1, 2):
            size = args[0]
            aspectRatioMode = Qt.IgnoreAspectRatio
            if len(args) == 2:
                aspectRatioMode = args[-1]
            image = QImage(size, QImage.Format_ARGB32_Premultiplied)
            image.fill(0)
            r = QRect(0, 0, size.width(), size.height())
            painter = QPainter(image)
            self.render(painter, r, aspectRatioMode)
            return image
开发者ID:berrosse,项目名称:PythonQwt,代码行数:57,代码来源:graphic.py


示例8: drawSeries

    def drawSeries(self, seriesItem, from_, to):
        """When observing an measurement while it is running, new points have 
        to be added to an existing seriesItem. drawSeries() can be used to 
        display them avoiding a complete redraw of the canvas.

        Setting plot().canvas().setAttribute(Qt.WA_PaintOutsidePaintEvent, True)
        will result in faster painting, if the paint engine of the canvas widget
        supports this feature."""
        if seriesItem is None or seriesItem.plot() is None:
            return
        canvas = seriesItem.plot().canvas()
        canvasRect = canvas.contentsRect()
        plotCanvas = canvas  #XXX: cast to QwtPlotCanvas
        if plotCanvas and qwtHasBackingStore(plotCanvas):
            painter = QPainter(plotCanvas.backingStore())  #XXX: cast plotCanvas.backingStore() to QPixmap
            if self.__data.hasClipping:
                painter.setClipRegion(self.__data.clipRegion)
            qwtRenderItem(painter, canvasRect, seriesItem, from_, to)
            if self.testAttribute(self.FullRepaint):
                plotCanvas.repaint()
                return
        immediatePaint = True
        if not canvas.testAttribute(Qt.WA_WState_InPaintEvent):
            if QT_VERSION >= 0x050000 or\
               not canvas.testAttribute(Qt.WA_PaintOutsidePaintEvent):
                immediatePaint = False
        if immediatePaint:
            if not self.__data.painter.isActive():
                self.reset()
                self.__data.painter.begin(canvas)
                canvas.installEventFilter(self)
            if self.__data.hasClipping:
                self.__data.painter.setClipRegion(
                        QRegion(canvasRect) & self.__data.clipRegion)
            elif not self.__data.painter.hasClipping():
                self.__data.painter.setClipRect(canvasRect)
            qwtRenderItem(self.__data.painter,
                          canvasRect, seriesItem, from_, to)
            if self.__data.attributes & self.AtomicPainter:
                self.reset()
            elif self.__data.hasClipping:
                self.__data.painter.setClipping(False)
        else:
            self.reset()
            self.__data.seriesItem = seriesItem
            self.__data.from_ = from_
            self.__data.to = to
            clipRegion = QRegion(canvasRect)
            if self.__data.hasClipping:
                clipRegion &= self.__data.clipRegion
            canvas.installEventFilter(self)
            canvas.repaint(clipRegion)
            canvas.removeEventFilter(self)
            self.__data.seriesItem = None
开发者ID:petebachant,项目名称:python-qwt,代码行数:54,代码来源:plot_directpainter.py


示例9: drawSymbols

    def drawSymbols(self, painter, points, numPoints=None):
        """
        Render an array of symbols

        Painting several symbols is more effective than drawing symbols
        one by one, as a couple of layout calculations and setting of pen/brush
        can be done once for the complete array.

        :param QPainter painter: Painter
        :param QPolygonF points: Positions of the symbols in screen coordinates
        """
        #TODO: remove argument numPoints (not necessary in `PythonQwt`)
        if numPoints is not None and numPoints <= 0:
            return
        useCache = False
        if QwtPainter.roundingAlignment(painter) and\
           not painter.transform().isScaling():
            if self.__data.cache.policy == QwtSymbol.Cache:
                useCache = True
            elif self.__data.cache.policy == QwtSymbol.AutoCache:
                if painter.paintEngine().type() == QPaintEngine.Raster:
                    useCache = True
                else:
                    if self.__data.style in (QwtSymbol.XCross, QwtSymbol.HLine,
                                             QwtSymbol.VLine, QwtSymbol.Cross):
                        pass
                    elif self.__data.style == QwtSymbol.Pixmap:
                        if not self.__data.size.isEmpty() and\
                           self.__data.size != self.__data.pixmap.pixmap.size():
                            useCache = True
                    else:
                        useCache = True
        if useCache:
            br = QRect(self.boundingRect())
            rect = QRect(0, 0, br.width(), br.height())
            if self.__data.cache.pixmap.isNull():
                self.__data.cache.pixmap = QwtPainter.backingStore(None, br.size())
                self.__data.cache.pixmap.fill(Qt.transparent)
                p = QPainter(self.__data.cache.pixmap)
                p.setRenderHints(painter.renderHints())
                p.translate(-br.topLeft())
                pos = QPointF()
                self.renderSymbols(p, pos, 1)
            dx = br.left()
            dy = br.top()
            for point in points:
                left = round(point.x())+dx
                top = round(point.y())+dy
                painter.drawPixmap(left, top, self.__data.cache.pixmap)
        else:
            painter.save()
            self.renderSymbols(painter, points, numPoints)
            painter.restore()
开发者ID:gyenney,项目名称:Tools,代码行数:53,代码来源:symbol.py


示例10: paintEvent

 def paintEvent(self, event):
     painter = QPainter(self)
     if not self.contentsRect().contains(event.rect()):
         painter.save()
         painter.setClipRegion(event.region() & self.frameRect())
         self.drawFrame(painter)
         painter.restore()
     painter.setClipRegion(event.region() & self.contentsRect())
     self.drawContents(painter)
开发者ID:gyenney,项目名称:Tools,代码行数:9,代码来源:text.py


示例11: qwtPathGraphic

def qwtPathGraphic(path, pen, brush):
    graphic = QwtGraphic()
    graphic.setRenderHint(QwtGraphic.RenderPensUnscaled)
    painter = QPainter(graphic)
    painter.setPen(pen)
    painter.setBrush(brush)
    painter.drawPath(path)
    painter.end()
    return graphic
开发者ID:gyenney,项目名称:Tools,代码行数:9,代码来源:symbol.py


示例12: renderDocument

 def renderDocument(self, plot, filename, sizeMM=(300, 200), resolution=85,
                    format_=None):
     if isinstance(sizeMM, tuple):
         sizeMM = QSizeF(*sizeMM)
     if format_ is None:
         ext = osp.splitext(filename)[1]
         if not ext:
             raise TypeError("Unable to determine target format from filename")
         format_ = ext[1:]
     if plot is None or sizeMM.isEmpty() or resolution <= 0:
         return
     title = plot.title().text()
     if not title:
         title = "Plot Document"
     mmToInch = 1./25.4
     size = sizeMM * mmToInch * resolution
     documentRect = QRectF(0.0, 0.0, size.width(), size.height())
     fmt = format_.lower()
     if fmt in ("pdf", "ps"):
         printer = QPrinter()
         if fmt == "pdf":
             printer.setOutputFormat(QPrinter.PdfFormat)
         else:
             printer.setOutputFormat(QPrinter.PostScriptFormat)
         printer.setColorMode(QPrinter.Color)
         printer.setFullPage(True)
         printer.setPaperSize(sizeMM, QPrinter.Millimeter)
         printer.setDocName(title)
         printer.setOutputFileName(filename)
         printer.setResolution(resolution)
         painter = QPainter(printer)
         self.render(plot, painter, documentRect)
         painter.end()
     elif fmt == "svg":
         generator = QSvgGenerator()
         generator.setTitle(title)
         generator.setFileName(filename)
         generator.setResolution(resolution)
         generator.setViewBox(documentRect)
         painter = QPainter(generator)
         self.render(plot, painter, documentRect)
         painter.end()
     elif fmt in QImageWriter.supportedImageFormats():
         imageRect = documentRect.toRect()
         dotsPerMeter = int(round(resolution*mmToInch*1000.))
         image = QImage(imageRect.size(), QImage.Format_ARGB32)
         image.setDotsPerMeterX(dotsPerMeter)
         image.setDotsPerMeterY(dotsPerMeter)
         image.fill(QColor(Qt.white).rgb())
         painter = QPainter(image)
         self.render(plot, painter, imageRect)
         painter.end()
         image.save(filename, fmt)
     else:
         raise TypeError("Unsupported file format '%s'" % fmt)
开发者ID:petebachant,项目名称:python-qwt,代码行数:55,代码来源:plot_renderer.py


示例13: qwtBackgroundWidget

def qwtBackgroundWidget(w):
    if w.parentWidget() is None:
        return w
    if w.autoFillBackground():
        brush = w.palette().brush(w.backgroundRole())
        if brush.color().alpha() > 0:
            return w
    if w.testAttribute(Qt.WA_StyledBackground):
        image = QImage(1, 1, QImage.Format_ARGB32)
        image.fill(Qt.transparent)
        painter = QPainter(image)
        painter.translate(-w.rect().center())
        qwtDrawStyledBackground(w, painter)
        painter.end()
        if qAlpha(image.pixel(0, 0)) != 0:
            return w
    return qwtBackgroundWidget(w.parentWidget())
开发者ID:petebachant,项目名称:python-qwt,代码行数:17,代码来源:plot_canvas.py


示例14: qwtFillBackground

def qwtFillBackground(*args):
    if len(args) == 2:
        painter, canvas = args

        rects = []
        if canvas.testAttribute(Qt.WA_StyledBackground):
            recorder = QwtStyleSheetRecorder(canvas.size())
            p = QPainter(recorder)
            qwtDrawStyledBackground(canvas, p)
            p.end()
            if recorder.background.brush.isOpaque():
                rects = recorder.clipRects
            else:
                rects += [canvas.rect()]
        else:
            r = canvas.rect()
            radius = canvas.borderRadius()
            if radius > 0.:
                sz = QSizeF(radius, radius)
                rects += [QRectF(r.topLeft(), sz),
                          QRectF(r.topRight()-QPointF(radius, 0), sz),
                          QRectF(r.bottomRight()-QPointF(radius, radius), sz),
                          QRectF(r.bottomLeft()-QPointF(0, radius), sz)]

        qwtFillBackground(painter, canvas, rects)

    elif len(args) == 3:
        painter, widget, fillRects = args
        
        if not fillRects:
            return
        if painter.hasClipping():
            clipRegion = painter.transform().map(painter.clipRegion())
        else:
            clipRegion = widget.contentsRect()
        bgWidget = qwtBackgroundWidget(widget.parentWidget())
        for fillRect in fillRects:
            rect = fillRect.toAlignedRect()
            if clipRegion.intersects(rect):
                pm = QPixmap(rect.size())
                QwtPainter.fillPixmap(bgWidget, pm, widget.mapTo(bgWidget, rect.topLeft()))
                painter.drawPixmap(rect, pm)
        
    else:
        raise TypeError("%s() takes 2 or 3 argument(s) (%s given)"\
                        % ("qwtFillBackground", len(args)))
开发者ID:petebachant,项目名称:python-qwt,代码行数:46,代码来源:plot_canvas.py


示例15: legendIcon

    def legendIcon(self, index, size):
        if size.isEmpty():
            return QwtGraphic()
        graphic = QwtGraphic()
        graphic.setDefaultSize(size)
        graphic.setRenderHint(QwtGraphic.RenderPensUnscaled, True)
        painter = QPainter(graphic)
        painter.setRenderHint(QPainter.Antialiasing,
                          self.testRenderHint(QwtPlotItem.RenderAntialiased))
        if self.__data.legendAttributes == 0 or\
           (self.__data.legendAttributes & QwtPlotCurve.LegendShowBrush):
            brush = self.__data.brush
            if brush.style() == Qt.NoBrush and self.__data.legendAttributes == 0:
                if self.style() != QwtPlotCurve.NoCurve:
                    brush = QBrush(self.pen().color())
                elif self.__data.symbol and\
                     self.__data.symbol.style() != QwtSymbol.NoSymbol:
                    brush = QBrush(self.__data.symbol.pen().color())
            if brush.style() != Qt.NoBrush:
                r = QRectF(0, 0, size.width(), size.height())
                painter.fillRect(r, brush)
        if self.__data.legendAttributes & QwtPlotCurve.LegendShowLine:
            if self.pen() != Qt.NoPen:
                pn = self.pen()
#                pn.setCapStyle(Qt.FlatCap)
                painter.setPen(pn)
                y = .5*size.height()
                QwtPainter.drawLine(painter, 0., y, size.width(), y)
        if self.__data.legendAttributes & QwtPlotCurve.LegendShowSymbol:
            if self.__data.symbol:
                r = QRectF(0, 0, size.width(), size.height())
                self.__data.symbol.drawSymbol(painter, r)
        return graphic    
开发者ID:petebachant,项目名称:python-qwt,代码行数:33,代码来源:plot_curve.py


示例16: fillPixmap

 def fillPixmap(self, widget, pixmap, offset=None):
     if offset is None:
         offset = QPoint()
     rect = QRect(offset, pixmap.size())
     painter = QPainter(pixmap)
     painter.translate(-offset)
     autoFillBrush = widget.palette().brush(widget.backgroundRole())
     if not (widget.autoFillBackground() and autoFillBrush.isOpaque()):
         bg = widget.palette().brush(QPalette.Window)
         qwtFillRect(widget, painter, rect, bg)
     if widget.autoFillBackground():
         qwtFillRect(widget, painter, rect, autoFillBrush)
     if widget.testAttribute(Qt.WA_StyledBackground):
         painter.setClipRegion(rect)
         opt = QStyleOption()
         opt.initFrom(widget)
         widget.style().drawPrimitive(QStyle.PE_Widget, opt,
                                      painter, widget)
开发者ID:petebachant,项目名称:python-qwt,代码行数:18,代码来源:painter.py


示例17: updateStyleSheetInfo

 def updateStyleSheetInfo(self):
     if not self.testAttribute(Qt.WA_StyledBackground):
         return
     recorder = QwtStyleSheetRecorder(self.size())
     painter = QPainter(recorder)
     opt = QStyleOption()
     opt.initFrom(self)
     self.style().drawPrimitive(QStyle.PE_Widget, opt, painter, self)
     painter.end()
     self.__data.styleSheet.hasBorder = not recorder.border.rectList.isEmpty()
     self.__data.styleSheet.cornerRects = recorder.clipRects
     if recorder.background.path.isEmpty():
         if not recorder.border.rectList.isEmpty():
             self.__data.styleSheet.borderPath =\
                 qwtCombinePathList(self.rect(), recorder.border.pathlist)
     else:
         self.__data.styleSheet.borderPath = recorder.background.path
         self.__data.styleSheet.background.brush = recorder.background.brush
         self.__data.styleSheet.background.origin = recorder.background.origin
开发者ID:petebachant,项目名称:python-qwt,代码行数:19,代码来源:plot_canvas.py


示例18: drawSymbols

 def drawSymbols(self, painter, points, numPoints=None):
     #TODO: remove argument numPoints (not necessary in Python's qwt)
     if numPoints is not None and numPoints <= 0:
         return
     useCache = False
     if QwtPainter.roundingAlignment(painter) and\
        not painter.transform().isScaling():
         if self.__data.cache.policy == QwtSymbol.Cache:
             useCache = True
         elif self.__data.cache.policy == QwtSymbol.AutoCache:
             if painter.paintEngine().type() == QPaintEngine.Raster:
                 useCache = True
             else:
                 if self.__data.style in (QwtSymbol.XCross, QwtSymbol.HLine,
                                          QwtSymbol.VLine, QwtSymbol.Cross):
                     pass
                 elif self.__data.style == QwtSymbol.Pixmap:
                     if not self.__data.size.isEmpty() and\
                        self.__data.size != self.__data.pixmap.pixmap.size():
                         useCache = True
                 else:
                     useCache = True
     if useCache:
         br = QRect(self.boundingRect())
         rect = QRect(0, 0, br.width(), br.height())
         if self.__data.cache.pixmap.isNull():
             self.__data.cache.pixmap = QwtPainter.backingStore(None, br.size())
             self.__data.cache.pixmap.fill(Qt.transparent)
             p = QPainter(self.__data.cache.pixmap)
             p.setRenderHints(painter.renderHints())
             p.translate(-br.topLeft())
             pos = QPointF()
             self.renderSymbols(p, pos, 1)
         dx = br.left()
         dy = br.top()
         for point in points:
             left = round(point.x())+dx
             top = round(point.y())+dy
             painter.drawPixmap(left, top, self.__data.cache.pixmap)
     else:
         painter.save()
         self.renderSymbols(painter, points, numPoints)
         painter.restore()
开发者ID:petebachant,项目名称:python-qwt,代码行数:43,代码来源:symbol.py


示例19: legendIcon

 def legendIcon(self, index, size):
     if size.isEmpty():
         return QwtGraphic()
     icon = QwtGraphic()
     icon.setDefaultSize(size)
     icon.setRenderHint(QwtGraphic.RenderPensUnscaled, True)
     painter = QPainter(icon)
     painter.setRenderHint(QPainter.Antialiasing,
                       self.testRenderHint(QwtPlotItem.RenderAntialiased))
     if self.__data.style != QwtPlotMarker.NoLine:
         painter.setPen(self.__data.pen)
         if self.__data.style in (QwtPlotMarker.HLine, QwtPlotMarker.Cross):
             y = .5*size.height()
             QwtPainter.drawLine(painter, 0., y, size.width(), y)
         if self.__data.style in (QwtPlotMarker.VLine, QwtPlotMarker.Cross):
             x = .5*size.width()
             QwtPainter.drawLine(painter, x, 0., x, size.height())
     if self.__data.symbol:
         r = QRect(0, 0, size.width(), size.height())
         self.__data.symbol.drawSymbol(painter, r)
     return icon
开发者ID:petebachant,项目名称:python-qwt,代码行数:21,代码来源:plot_marker.py


示例20: borderPath

 def borderPath(self, rect):
     if self.testAttribute(Qt.WA_StyledBackground):
         recorder = QwtStyleSheetRecorder(rect.size())
         painter = QPainter(recorder)
         opt = QStyleOption()
         opt.initFrom(self)
         opt.rect = rect
         self.style().drawPrimitive(QStyle.PE_Widget, opt, painter, self)
         painter.end()
         if not recorder.background.path.isEmpty():
             return recorder.background.path
         if not recorder.border.rectList.isEmpty():
             return qwtCombinePathList(rect, recorder.border.pathlist)
     elif self.__data.borderRadius > 0.:
         fw2 = self.frameWidth()*.5
         r = QRectF(rect).adjusted(fw2, fw2, -fw2, -fw2)
         path = QPainterPath()
         path.addRoundedRect(r, self.__data.borderRadius,
                             self.__data.borderRadius)
         return path
     return QPainterPath()
开发者ID:petebachant,项目名称:python-qwt,代码行数:21,代码来源:plot_canvas.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python r.cmd函数代码示例发布时间:2022-05-26
下一篇:
Python QtGui.QApplication类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap