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


Python QtGui.QPainter方法代码示例

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


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

示例1: lineNumberAreaPaintEvent

# 需要导入模块: from PySide import QtGui [as 别名]
# 或者: from PySide.QtGui import QPainter [as 别名]
def lineNumberAreaPaintEvent(self, event):
        painter = QPainter(self.lineNumberArea)
        painter.fillRect(event.rect(), Qt.lightGray)

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

        while (block.isValid() and top <= event.rect().bottom()):
            if (block.isValid and bottom >= event.rect().top()):
                number = str(blockNumber + 1)
                painter.setPen(QtCore.Qt.black)
                painter.drawText(0, top, self.lineNumberArea.width(),
                                 self.fontMetrics().height(),
                                 QtCore.Qt.AlignCenter, number)
            block = block.next()
            top = bottom
            bottom = top + self.blockBoundingRect(block).height()
            blockNumber += 1 
开发者ID:jmwright,项目名称:cadquery-freecad-module,代码行数:22,代码来源:CodeEditor.py

示例2: getIcon

# 需要导入模块: from PySide import QtGui [as 别名]
# 或者: from PySide.QtGui import QPainter [as 别名]
def getIcon(obj,disabled=False,path=None):
    if not path:
        path = iconPath
    if not getattr(obj,'_icon',None):
        obj._icon = addIconToFCAD(obj._iconName,path)
    if not disabled:
        return obj._icon
    if not getattr(obj,'_iconDisabled',None):
        name = getattr(obj,'_iconDisabledName',None)
        if name:
            obj._iconDisabled = addIconToFCAD(name,path)
        else:
            key = os.path.join(path,obj._iconName) + '.disabled'
            fmt = None
            try:
                if FreeCADGui.isIconCached(key):
                    obj._iconDisabled = key
                    return key
                else:
                    fmt = 'PNG'
            except Exception:
                pass
            pixmap = FreeCADGui.getIcon(obj._icon).pixmap(*iconSize,mode=QIcon.Disabled)
            icon = QIcon(pixmapDisabled)
            icon.paint(QPainter(pixmap),0,0,iconSize[0],iconSize[1],Qt.AlignCenter)
            data = QByteArray()
            buf = QBuffer(data)
            buf.open(QIODevice.WriteOnly)
            if fmt:
                pixmap.save(buf, fmt)
                FreeCADGui.addIcon(key,data.data(),fmt)
            else:
                pixmap.save(buf, 'XPM')
                key = data.data().decode('latin1')
            obj._iconDisabled = key
    return obj._iconDisabled 
开发者ID:realthunder,项目名称:FreeCAD_assembly3,代码行数:38,代码来源:utils.py

示例3: get_icon

# 需要导入模块: from PySide import QtGui [as 别名]
# 或者: from PySide.QtGui import QPainter [as 别名]
def get_icon(icon, size=24):
    """get svg icon from icon resources folder as a pixel map
    """
    img = get_icon_path("{}.svg".format(icon))
    svg_renderer = QtSvg.QSvgRenderer(img)
    image = QtGui.QImage(size, size, QtGui.QImage.Format_ARGB32)
    # Set the ARGB to 0 to prevent rendering artifacts
    image.fill(0x00000000)
    svg_renderer.render(QtGui.QPainter(image))
    pixmap = QtGui.QPixmap.fromImage(image)

    return pixmap 
开发者ID:mgear-dev,项目名称:mgear_core,代码行数:14,代码来源:pyqt.py

示例4: _paint_points

# 需要导入模块: from PySide import QtGui [as 别名]
# 或者: from PySide.QtGui import QPainter [as 别名]
def _paint_points(self, img, points):
        painter = QtGui.QPainter(img)
        painter.setRenderHint(QtGui.QPainter.Antialiasing)

        pen = QtGui.QPen(QtGui.QColor(0, 0, 0, 0))
        pen.setWidth(0)
        painter.setPen(pen)

        for point in points:
            self._paint_point(painter, *point)
        painter.end() 
开发者ID:LumenResearch,项目名称:heatmappy,代码行数:13,代码来源:heatmap.py

示例5: get_QPainter

# 需要导入模块: from PySide import QtGui [as 别名]
# 或者: from PySide.QtGui import QPainter [as 别名]
def get_QPainter():
    """QPainter getter."""

    try:
        import PySide.QtGui as QtGui
        return QtGui.QPainter
    except ImportError:
        import PyQt5.QtGui as QtGui
        return QtGui.QPainter 
开发者ID:AirbusCyber,项目名称:grap,代码行数:11,代码来源:QtShim.py

示例6: numberbarPaint

# 需要导入模块: from PySide import QtGui [as 别名]
# 或者: from PySide.QtGui import QPainter [as 别名]
def numberbarPaint(self, number_bar, event):
            font_metrics = self.fontMetrics()
            current_line = self.document().findBlock(self.textCursor().position()).blockNumber() + 1
 
            block = self.firstVisibleBlock()
            line_count = block.blockNumber()
            painter = QtGui.QPainter(number_bar)
            painter.fillRect(event.rect(), self.palette().base())
 
            # Iterate over all visible text blocks in the document.
            while block.isValid():
                line_count += 1
                block_top = self.blockBoundingGeometry(block).translated(self.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 line_count == current_line:
                    font = painter.font()
                    font.setBold(True)
                    painter.setFont(font)
                else:
                    font = painter.font()
                    font.setBold(False)
                    painter.setFont(font)
 
                # Draw the line number right justified at the position of the line.
                paint_rect = QtCore.QRect(0, block_top, number_bar.width(), font_metrics.height())
                painter.drawText(paint_rect, QtCore.Qt.AlignRight, unicode(line_count))
 
                block = block.next()
 
            painter.end() 
开发者ID:shiningdesign,项目名称:universal_tool_template.py,代码行数:38,代码来源:LNTextEdit.py

示例7: paintEvent

# 需要导入模块: from PySide import QtGui [as 别名]
# 或者: from PySide.QtGui import QPainter [as 别名]
def paintEvent(self, e):

        painter = QtGui.QPainter()
        painter.begin(self)
        self.drawBars(painter)
        painter.end() 
开发者ID:xiongyihui,项目名称:tdoa,代码行数:8,代码来源:bar_widget.py


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