本文整理汇总了Python中PySide.QtGui.QPainter.end方法的典型用法代码示例。如果您正苦于以下问题:Python QPainter.end方法的具体用法?Python QPainter.end怎么用?Python QPainter.end使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PySide.QtGui.QPainter
的用法示例。
在下文中一共展示了QPainter.end方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: paintEvent
# 需要导入模块: from PySide.QtGui import QPainter [as 别名]
# 或者: from PySide.QtGui.QPainter import end [as 别名]
def paintEvent(self, event):
painter = QPainter()
painter.begin(self)
painter.setRenderHint(QPainter.HighQualityAntialiasing)
painter.setRenderHint(QPainter.Antialiasing)
painter.setRenderHint(QPainter.SmoothPixmapTransform)
# change the look for on/off
if self.isChecked():
# blue fill
brush = QBrush(self.color1)
painter.setBrush(brush)
painter.drawRoundedRect(0, 7, self.width() - 2, self.height() - 15, self.height() / 2 - 10,
self.height() / 2)
brush = QBrush(self.lighter(self.color1))
painter.setBrush(brush)
painter.drawEllipse(self.width() - self.height(), 0, self.height(), self.height())
else:
# gray fill
brush = QBrush(self.color2)
painter.setBrush(brush)
painter.drawRoundedRect(1, 7, self.width() - 3, self.height() - 15, self.height() / 2 - 10,
self.height() / 2)
brush = QBrush(QColor(100, 100, 100))
painter.setBrush(brush)
painter.drawEllipse(0, 0, self.height(), self.height())
painter.end()
示例2: paintEvent
# 需要导入模块: from PySide.QtGui import QPainter [as 别名]
# 或者: from PySide.QtGui.QPainter import end [as 别名]
def paintEvent(self, event):
contents_y = self.edit.verticalScrollBar().value()
page_bottom = contents_y + self.edit.viewport().height()
font_metrics = self.fontMetrics()
current_block = self.edit.document().findBlock(self.edit.textCursor().position())
painter = QPainter(self)
line_count = 0
block = self.edit.document().begin()
while block.isValid():
line_count += 1
position = self.edit.document().documentLayout().blockBoundingRect(block).topLeft()
if position.y() > page_bottom:
break
bold = False
if block == current_block:
bold = True
font = painter.font()
font.setBold(True)
painter.setFont(font)
self.current = line_count
painter.drawText(
self.width() - font_metrics.width(str(line_count)) - 10,
round(position.y()) - contents_y + font_metrics.ascent(),
str(line_count),
)
if bold:
font = painter.font()
font.setBold(False)
painter.setFont(font)
block = block.next()
self.highest_line = line_count
painter.end()
QWidget.paintEvent(self, event)
示例3: capture
# 需要导入模块: from PySide.QtGui import QPainter [as 别名]
# 或者: from PySide.QtGui.QPainter import end [as 别名]
def capture(self, region=None, selector=None,
format=QImage.Format_ARGB32_Premultiplied):
"""Returns snapshot as QImage.
:param region: An optional tuple containing region as pixel
coodinates.
:param selector: A selector targeted the element to crop on.
:param format: The output image format.
"""
if region is None and selector is not None:
region = self.region_for_selector(selector)
if region:
x1, y1, x2, y2 = region
w, h = (x2 - x1), (y2 - y1)
image = QImage(QSize(x2, y2), format)
painter = QPainter(image)
self.main_frame.render(painter)
painter.end()
image = image.copy(x1, y1, w, h)
else:
self.main_frame.setScrollBarPolicy(QtCore.Qt.Vertical,
QtCore.Qt.ScrollBarAlwaysOff)
self.main_frame.setScrollBarPolicy(QtCore.Qt.Horizontal,
QtCore.Qt.ScrollBarAlwaysOff)
self.page.setViewportSize(self.main_frame.contentsSize())
image = QImage(self.page.viewportSize(), format)
painter = QPainter(image)
self.main_frame.render(painter)
painter.end()
return image
示例4: paint
# 需要导入模块: from PySide.QtGui import QPainter [as 别名]
# 或者: from PySide.QtGui.QPainter import end [as 别名]
def paint(self, canvas, is_secondary_color=False, additional_flag=False):
pen = QPen()
if is_secondary_color:
pen.setColor(self.data_singleton.secondary_color)
else:
pen.setColor(self.data_singleton.primary_color)
painter = QPainter(canvas.image)
painter.setRenderHint(QPainter.Antialiasing)
pen.setWidth(self.data_singleton.pen_size)
pen.setStyle(Qt.SolidLine)
pen.setCapStyle(Qt.RoundCap)
pen.setJoinStyle(Qt.RoundJoin)
painter.setPen(pen)
if is_secondary_color:
painter.setBrush(self.data_singleton.primary_color)
else:
painter.setBrush(self.data_singleton.secondary_color)
if self._start_point != self._end_point:
painter.drawRect(QRect(self._start_point, self._end_point))
painter.end()
canvas.edited = True
canvas.update()
示例5: paintEvent
# 需要导入模块: from PySide.QtGui import QPainter [as 别名]
# 或者: from PySide.QtGui.QPainter import end [as 别名]
def paintEvent(self, e):
painter = QPainter()
painter.begin(self)
width = self.width()
height = self.height()
#Blank out the world
painter.fillRect(0, 0, width, height, Qt.white)
#Compute width/height of the columns and rows
#Reserve pixels for the grid lines
colWidth = (width - (self._NUM_COLS - 1) * self._GRID_SIZE) / self._NUM_COLS
rowHeight = (height - (self._NUM_ROWS - 1) * self._GRID_SIZE) / self._NUM_ROWS
colWidth = max(1, colWidth)
rowHeight = max(1, rowHeight)
#Perform drawing operations for world rendering
self._drawGrid(width, height, colWidth, rowHeight, painter)
self._drawObstacles(colWidth, rowHeight, painter)
if self._drawVisited:
self._drawVisitedCells(colWidth, rowHeight, painter)
if self._drawActive:
self._drawActiveCells(colWidth, rowHeight, painter)
self._drawStartAndEndCells(colWidth, rowHeight, painter)
self._drawCurrentCell(colWidth, rowHeight, painter)
if self._drawCheapestPath:
self._drawPath(colWidth, rowHeight, painter)
painter.end()
示例6: __init__
# 需要导入模块: from PySide.QtGui import QPainter [as 别名]
# 或者: from PySide.QtGui.QPainter import end [as 别名]
def __init__(self, parent, scene, view):
super(QNodesEditor, self).__init__(parent)
self.scene = scene
self.scene.installEventFilter(self)
gridSize = 25
gridMap = QPixmap(gridSize,gridSize)
gridPainter = QPainter(gridMap)
gridPainter.fillRect(0,0,gridSize,gridSize, QApplication.palette().window().color().darker(103))
gridPainter.fillRect(1,1,gridSize-2,gridSize-2, QApplication.palette().window())
gridPainter.end()
self.scene.setBackgroundBrush( QBrush(gridMap) )
originSize = 50
originItem = QGraphicsPathItem()
path = QPainterPath()
path.moveTo(0,-originSize)
path.lineTo(0,originSize)
path.moveTo(-originSize,0)
path.lineTo(originSize,0)
originItem.setPath(path)
originItem.setPen(QPen(QApplication.palette().window().color().darker(110),2))
originItem.setZValue(-2)
self.scene.addItem(originItem)
self.view = view
self.view.setDragMode(QGraphicsView.RubberBandDrag)
self.view.setRenderHint(QPainter.Antialiasing)
self.connection = None
示例7: render
# 需要导入模块: from PySide.QtGui import QPainter [as 别名]
# 或者: from PySide.QtGui.QPainter import end [as 别名]
def render(self, fileName, width, height):
self.setViewportSize(QSize(width, height))
fileInfo = QFileInfo(fileName)
dir = QDir()
dir.mkpath(fileInfo.absolutePath())
viewportSize = self.viewportSize()
pageSize = self.mainFrame().contentsSize()
if pageSize.isEmpty():
return False
buffer = QImage(pageSize, QImage.Format_ARGB32)
buffer.fill(qRgba(255, 255, 255, 0))
p = QPainter(buffer)
p.setRenderHint( QPainter.Antialiasing, True)
p.setRenderHint( QPainter.TextAntialiasing, True)
p.setRenderHint( QPainter.SmoothPixmapTransform, True)
self.setViewportSize(pageSize)
self.mainFrame().render(p)
p.end()
self.setViewportSize(viewportSize)
return buffer.save(fileName)
示例8: paintEvent
# 需要导入模块: from PySide.QtGui import QPainter [as 别名]
# 或者: from PySide.QtGui.QPainter import end [as 别名]
def paintEvent(self, event):
painter = QPainter()
painter.begin(self)
painter.save()
self.rect = painter.viewport()
self.rect.adjust(0, 0, -1, -1)
painter.drawRect(QRectF(self.rect))
self.prj.setupPrism(self.rect.height(), 68)
self.prj.setupProjectionMatrix(self.alef, self.bet)
# draw the prism
self.drawCubick(painter, [0, 0, 0], 63, 16)
mineCube = self.parent.presenter.mineCube
for y in range(len(mineCube)):
for z in range(len(mineCube[0])):
for x in range(len(mineCube[0][0])):
if mineCube[y][z][x] in self.parent.selectedMinerals.list_:
colo = self.parent.selectedMinerals.\
getColor(mineCube[y][z][x])
self.drawCubick(painter, [x, y, z], color=colo)
self.drawSliceCursor(painter, self.parent.presenter.elevation)
painter.restore()
painter.end()
del painter
示例9: set_clipboard_image
# 需要导入模块: from PySide.QtGui import QPainter [as 别名]
# 或者: from PySide.QtGui.QPainter import end [as 别名]
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)
示例10: SetImageTransparency
# 需要导入模块: from PySide.QtGui import QPainter [as 别名]
# 或者: from PySide.QtGui.QPainter import end [as 别名]
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)
示例11: paint
# 需要导入模块: from PySide.QtGui import QPainter [as 别名]
# 或者: from PySide.QtGui.QPainter import end [as 别名]
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())
示例12: _update_cursor
# 需要导入模块: from PySide.QtGui import QPainter [as 别名]
# 或者: from PySide.QtGui.QPainter import end [as 别名]
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)
示例13: capture
# 需要导入模块: from PySide.QtGui import QPainter [as 别名]
# 或者: from PySide.QtGui.QPainter import end [as 别名]
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)
示例14: paintEvent
# 需要导入模块: from PySide.QtGui import QPainter [as 别名]
# 或者: from PySide.QtGui.QPainter import end [as 别名]
def paintEvent(self, event):
text = []
text.append(['{0}; {1}'.format(self.parent.chunkData['X'], self.parent.chunkData['Y']), Qt.black])
if self.parent.chunkData[14] > 0:
text.append(['Gold = {0}'.format(self.parent.chunkData[14]), Qt.yellow])
else:
text.append(['', Qt.yellow])
if self.parent.chunkData[15] > 0:
text.append(['Iron = {0}'.format(self.parent.chunkData[15]), Qt.red])
else:
text.append(['', Qt.red])
if self.parent.chunkData[56] > 0:
text.append(['Diamond = {0}'.format(self.parent.chunkData[56]), Qt.cyan])
else:
text.append(['', Qt.cyan])
if self.parent.chunkData[73] > 0:
text.append(['Redstone = {0}'.format(self.parent.chunkData[73]), Qt.magenta])
else:
text.append(['', Qt.magenta])
if self.parent.chunkData[49] > 0:
text.append(['Obsidian = {0}'.format(self.parent.chunkData[49]), Qt.darkYellow])
else:
text.append(['', Qt.darkYellow])
if self.parent.chunkData[21] > 0:
text.append(['Lazurit = {0}'.format(self.parent.chunkData[21]), Qt.darkBlue])
else:
text.append(['', Qt.darkBlue])
painter = QPainter()
painter.begin(self)
painter.drawRect(self.parent.leftMargin, self.parent.topMargin,
self.edgeLen, self.edgeLen)
cX = self.parent.leftMargin + self.parent.vsepara
cY = self.parent.topMargin + self.parent.hsepara
alig = Qt.AlignCenter
i = 0
fontik = painter.font()
for t in text:
if i > 0:
alig = Qt.AlignLeft
painter.setPen(t[1])
if i == 2:
fontik.setUnderline(True)
else:
fontik.setUnderline(False)
painter.setFont(fontik)
painter.drawText(cX, cY, self.tBoxWidth, self.tBoxHeight, alig, t[0])
cY += self.lineSpacing
i += 1
painter.end()
del painter
示例15: paintEvent
# 需要导入模块: from PySide.QtGui import QPainter [as 别名]
# 或者: from PySide.QtGui.QPainter import end [as 别名]
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()