當前位置: 首頁>>代碼示例>>Python>>正文


Python QPainter.setBrush方法代碼示例

本文整理匯總了Python中qwt.qt.QtGui.QPainter.setBrush方法的典型用法代碼示例。如果您正苦於以下問題:Python QPainter.setBrush方法的具體用法?Python QPainter.setBrush怎麽用?Python QPainter.setBrush使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在qwt.qt.QtGui.QPainter的用法示例。


在下文中一共展示了QPainter.setBrush方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: qwtPathGraphic

# 需要導入模塊: from qwt.qt.QtGui import QPainter [as 別名]
# 或者: from qwt.qt.QtGui.QPainter import setBrush [as 別名]
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,代碼行數:11,代碼來源:symbol.py

示例2: qwtDrawBackground

# 需要導入模塊: from qwt.qt.QtGui import QPainter [as 別名]
# 或者: from qwt.qt.QtGui.QPainter import setBrush [as 別名]
def qwtDrawBackground(painter, canvas):
    painter.save()
    borderClip = canvas.borderPath(canvas.rect())
    if not borderClip.isEmpty():
        painter.setClipPath(borderClip, Qt.IntersectClip)
    brush = canvas.palette().brush(canvas.backgroundRole())
    if brush.style() == Qt.TexturePattern:
        pm = QPixmap(canvas.size())
        QwtPainter.fillPixmap(canvas, pm)
        painter.drawPixmap(0, 0, pm)
    elif brush.gradient():
        rects = []
        if brush.gradient().coordinateMode() == QGradient.ObjectBoundingMode:
            rects += [canvas.rect()]
        else:
            rects += [painter.clipRegion().rects()]
        useRaster = False
        if painter.paintEngine().type() == QPaintEngine.X11:
            useRaster = True
        if useRaster:
            format_ = QImage.Format_RGB32
            stops = brush.gradient().stops()
            for stop in stops:
                if stop.second.alpha() != 255:
                    format_ = QImage.Format_ARGB32
                    break
            image = QImage(canvas.size(), format_)
            p = QPainter(image)
            p.setPen(Qt.NoPen)
            p.setBrush(brush)
            p.drawRects(_rects_conv_PyQt5(rects))
            p.end()
            painter.drawImage(0, 0, image)
        else:
            painter.setPen(Qt.NoPen)
            painter.setBrush(brush)
            painter.drawRects(_rects_conv_PyQt5(rects))
    else:
        painter.setPen(Qt.NoPen)
        painter.setBrush(brush)
        painter.drawRects(_rects_conv_PyQt5(painter.clipRegion().rects()))

    painter.restore()
開發者ID:petebachant,項目名稱:python-qwt,代碼行數:45,代碼來源:plot_canvas.py


注:本文中的qwt.qt.QtGui.QPainter.setBrush方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。