本文整理汇总了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
示例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
示例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
示例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()
示例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
示例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()
示例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()