本文整理汇总了Python中PyQt5.QtGui.QPaintEvent方法的典型用法代码示例。如果您正苦于以下问题:Python QtGui.QPaintEvent方法的具体用法?Python QtGui.QPaintEvent怎么用?Python QtGui.QPaintEvent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtGui
的用法示例。
在下文中一共展示了QtGui.QPaintEvent方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: paintEvent
# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QPaintEvent [as 别名]
def paintEvent(self, evt: QPaintEvent):
if not self.psuedo_line:
self.psuedo_line = 1
return
x = y = 0
y += self.fontMetrics().ascent()
painter = QPainter(self)
self.draw_text_n_outline(
painter,
x,
y + config.outline_top_padding - config.outline_bottom_padding,
config.outline_thickness,
config.outline_blur,
text = self.line
)
示例2: paintEvent
# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QPaintEvent [as 别名]
def paintEvent(self, event: QPaintEvent):
if self.isVisible():
block: QTextBlock = self.editor.firstVisibleBlock()
height: int = self.fontMetrics().height()
number: int = block.blockNumber()
painter = QPainter(self)
painter.fillRect(event.rect(), QColor(53, 53, 53))
# painter.drawRect(0, 0, event.rect().width() - 1, event.rect().height() - 1)
font = painter.font()
font.setPointSize(15)
for blocks in self.editor.currentlyVisibleBlocks:
bl: QTextBlock = blocks[-1]
blockGeometry: QRectF = self.editor.blockBoundingGeometry(bl)
offset: QPointF = self.editor.contentOffset()
blockTop: float = float(blockGeometry.translated(offset).top() + 2)
rect: QRect = QRect(0, blockTop, self.width(), height)
painter.drawText(rect, Qt.AlignRight, str(bl.blockNumber() + 1))
painter.end()
示例3: event
# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QPaintEvent [as 别名]
def event(self, e):
if not isinstance(e, (
QtCore.QEvent,
QtCore.QChildEvent,
QtCore.QDynamicPropertyChangeEvent,
QtGui.QPaintEvent,
QtGui.QHoverEvent,
QtGui.QMoveEvent,
QtGui.QEnterEvent,
QtGui.QResizeEvent,
QtGui.QShowEvent,
QtGui.QPlatformSurfaceEvent,
QtGui.QWindowStateChangeEvent,
QtGui.QKeyEvent,
QtGui.QWheelEvent,
QtGui.QMouseEvent,
QtGui.QFocusEvent,
QtGui.QHelpEvent,
QtGui.QHideEvent,
QtGui.QCloseEvent,
QtGui.QInputMethodQueryEvent,
QtGui.QContextMenuEvent,
)):
log().warning("unknown event: %r %r", e.type(), e)
return super().event(e)
示例4: paintEvent
# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QPaintEvent [as 别名]
def paintEvent(self, a0: QtGui.QPaintEvent) -> None:
qp = QtGui.QPainter(self)
self.drawChart(qp)
self.drawValues(qp)
qp.end()
示例5: paintEvent
# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QPaintEvent [as 别名]
def paintEvent(self, a0: QtGui.QPaintEvent) -> None:
qp = QtGui.QPainter(self)
self.drawChart(qp)
self.drawValues(qp)
if (len(self.data) > 0 and
(self.data[0].freq > self.fstop or
self.data[len(self.data)-1].freq < self.fstart)
and
(len(self.reference) == 0 or
self.reference[0].freq > self.fstop or
self.reference[len(self.reference)-1].freq < self.fstart)):
# Data outside frequency range
qp.setBackgroundMode(QtCore.Qt.OpaqueMode)
qp.setBackground(self.backgroundColor)
qp.setPen(self.textColor)
qp.drawText(self.leftMargin + self.chartWidth/2 - 70,
self.topMargin + self.chartHeight/2 - 20,
"Data outside frequency span")
if self.draggedBox and self.draggedBoxCurrent[0] != -1:
dashed_pen = QtGui.QPen(self.foregroundColor, 1, QtCore.Qt.DashLine)
qp.setPen(dashed_pen)
top_left = QtCore.QPoint(self.draggedBoxStart[0], self.draggedBoxStart[1])
bottom_right = QtCore.QPoint(self.draggedBoxCurrent[0], self.draggedBoxCurrent[1])
rect = QtCore.QRect(top_left, bottom_right)
qp.drawRect(rect)
qp.end()
示例6: paintEvent
# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QPaintEvent [as 别名]
def paintEvent(self, a0: QtGui.QPaintEvent) -> None:
qp = QtGui.QPainter(self)
# qp.begin(self) # Apparently not needed?
self.drawSmithChart(qp)
self.drawValues(qp)
qp.end()
示例7: paintEvent
# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QPaintEvent [as 别名]
def paintEvent(self, event: QtGui.QPaintEvent) -> None:
painter = QtGui.QPainter()
painter.begin(self)
self.draw_border(painter)
self.draw_apple(painter)
self.draw_snake(painter)
painter.end()
示例8: paintEvent
# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QPaintEvent [as 别名]
def paintEvent(self, event: QtGui.QPaintEvent) -> None:
painter = QtGui.QPainter()
painter.begin(self)
self.show_network(painter)
painter.end()
示例9: paintEvent
# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QPaintEvent [as 别名]
def paintEvent(self, event: QPaintEvent):
if self.isVisible():
block: QTextBlock = self.editor.firstVisibleBlock()
height: int = self.fontMetrics().height()
number: int = block.blockNumber()
painter = QPainter(self)
painter.fillRect(event.rect(), QColor(53, 53, 53))
font = painter.font()
font.setPointSize(15)
for blocks in self.editor.currentlyVisibleBlocks:
bl: QTextBlock = blocks[-1]
blockGeometry: QRectF = self.editor.blockBoundingGeometry(bl)
offset: QPointF = self.editor.contentOffset()
blockTop: int = int(blockGeometry.translated(offset).top() + 1)
pattern = re.compile(
"\\s*(def|class|with|if|else|elif|for|while|async).*:")
if pattern.match(bl.text()):
options = QStyleOptionViewItem()
options.rect = QRect(0, blockTop, self.width(), height)
options.state = (QStyle.State_Active |
QStyle.State_Item |
QStyle.State_Children)
if bl.userState() == UNFOLDED_STATE:
options.state |= QStyle.State_Open
self.style().drawPrimitive(QStyle.PE_IndicatorBranch, options,
painter, self)
painter.end()
示例10: drawLines
# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QPaintEvent [as 别名]
def drawLines(self, event: QPaintEvent):
pass
示例11: paintEvent
# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QPaintEvent [as 别名]
def paintEvent(self, e: QtGui.QPaintEvent) -> None:
if self.isChecked():
self.setIcon(self._checked_icon)
else:
self.setIcon(self._unchecked_icon)
super(SwitchButton, self).paintEvent(e)
示例12: paintEvent
# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QPaintEvent [as 别名]
def paintEvent(self, event: QtGui.QPaintEvent) -> None:
"""
Reimplement this method of parent to update current max_ix value.
"""
view = self._first_plot.getViewBox()
view_range = view.viewRange()
self._right_ix = max(0, view_range[0][1])
super().paintEvent(event)
示例13: paintEvent
# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QPaintEvent [as 别名]
def paintEvent(self, event: QPaintEvent) -> None:
painter = QStylePainter(self)
opt = QStyleOptionSlider()
self.initStyleOption(opt)
font = painter.font()
font.setPixelSize(11)
painter.setFont(font)
if self.tickPosition() != QSlider.NoTicks:
x = 8
for i in range(self.minimum(), self.width(), 8):
if i % 5 == 0:
h, w, z = 18, 1, 13
else:
h, w, z = 8, 1, 23
tickcolor = QColor('#8F8F8F' if self.theme == 'dark' else '#444')
pen = QPen(tickcolor)
pen.setWidthF(w)
painter.setPen(pen)
if self.tickPosition() in (QSlider.TicksBothSides, QSlider.TicksAbove):
y = self.rect().top() + z
painter.drawLine(x, y, x, y + h)
if self.tickPosition() in (QSlider.TicksBothSides, QSlider.TicksBelow):
y = self.rect().bottom() - z
painter.drawLine(x, y, x, y - h)
if self.parent.mediaAvailable and i % 10 == 0 and (x + 4 + 50) < self.width():
painter.setPen(Qt.white if self.theme == 'dark' else Qt.black)
timecode = QStyle.sliderValueFromPosition(self.minimum(), self.maximum(), x - self.offset,
self.width() - (self.offset * 2))
timecode = self.parent.delta2QTime(timecode).toString(self.parent.runtimeformat)
painter.drawText(x + 4, y + 6, timecode)
if x + 30 > self.width():
break
x += 15
opt.subControls = QStyle.SC_SliderGroove
painter.drawComplexControl(QStyle.CC_Slider, opt)
if not len(self._progressbars) and (not self.parent.thumbnailsButton.isChecked() or self.thumbnailsOn):
for rect in self._regions:
rect.setY(int((self.height() - self._regionHeight) / 2) - 8)
rect.setHeight(self._regionHeight)
brushcolor = QColor(150, 190, 78, 200) if self._regions.index(rect) == self._regionSelected \
else QColor(237, 242, 255, 200)
painter.setBrush(brushcolor)
painter.setPen(QColor(50, 50, 50, 170))
painter.drawRect(rect)
opt.activeSubControls = opt.subControls = QStyle.SC_SliderHandle
painter.drawComplexControl(QStyle.CC_Slider, opt)