本文整理汇总了Python中PyQt5.QtGui.QRegion方法的典型用法代码示例。如果您正苦于以下问题:Python QtGui.QRegion方法的具体用法?Python QtGui.QRegion怎么用?Python QtGui.QRegion使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtGui
的用法示例。
在下文中一共展示了QtGui.QRegion方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QRegion [as 别名]
def __init__(self, parent):
super(DefinitionsUI, self).__init__()
self.setupUi(self)
self._translate = QtCore.QCoreApplication.translate
self.parent = parent
self.previous_position = None
self.setWindowFlags(
QtCore.Qt.Popup |
QtCore.Qt.FramelessWindowHint)
radius = 15
path = QtGui.QPainterPath()
path.addRoundedRect(QtCore.QRectF(self.rect()), radius, radius)
try:
mask = QtGui.QRegion(path.toFillPolygon().toPolygon())
self.setMask(mask)
except TypeError: # Required for older versions of Qt
pass
self.definitionView.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
self.app_id = 'bb7a91f9'
self.app_key = 'fefacdf6775c347b52e9efa2efe642ef'
self.root_url = 'https://od-api.oxforddictionaries.com:443/api/v1/inflections/'
self.define_url = 'https://od-api.oxforddictionaries.com:443/api/v1/entries/'
self.pronunciation_mp3 = None
self.okButton.clicked.connect(self.hide)
self.dialogBackground.clicked.connect(self.color_background)
if multimedia_available:
self.pronounceButton.clicked.connect(self.play_pronunciation)
else:
self.pronounceButton.setEnabled(False)
示例2: __init__
# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QRegion [as 别名]
def __init__(self, parent):
super(MetadataUI, self).__init__()
self.setupUi(self)
self._translate = QtCore.QCoreApplication.translate
self.setWindowFlags(
QtCore.Qt.Popup |
QtCore.Qt.FramelessWindowHint)
self.parent = parent
radius = 15
path = QtGui.QPainterPath()
path.addRoundedRect(QtCore.QRectF(self.rect()), radius, radius)
try:
mask = QtGui.QRegion(path.toFillPolygon().toPolygon())
self.setMask(mask)
except TypeError: # Required for older versions of Qt
pass
self.parent = parent
self.database_path = self.parent.database_path
self.book_index = None
self.book_year = None
self.previous_position = None
self.cover_for_database = None
self.coverView.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
self.coverView.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
self.okButton.clicked.connect(self.ok_pressed)
self.cancelButton.clicked.connect(self.cancel_pressed)
self.dialogBackground.clicked.connect(self.color_background)
self.titleLine.returnPressed.connect(self.ok_pressed)
self.authorLine.returnPressed.connect(self.ok_pressed)
self.yearLine.returnPressed.connect(self.ok_pressed)
self.tagsLine.returnPressed.connect(self.ok_pressed)
示例3: showEvent
# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QRegion [as 别名]
def showEvent(self, event=None):
# TODO
# See what happens when the size of the viewport is smaller
# than the size of the dock
viewport_bottomRight = self.contentView.mapToGlobal(
self.contentView.viewport().rect().bottomRight())
# Dock dimensions
desktop_size = QtWidgets.QDesktopWidget().screenGeometry()
dock_width = desktop_size.width() // 4.5
dock_height = 30
dock_x = viewport_bottomRight.x() - dock_width - 30
dock_y = viewport_bottomRight.y() - 70
self.main_window.active_docks.append(self)
self.setGeometry(dock_x, dock_y, dock_width, dock_height)
# Rounded
radius = 20
path = QtGui.QPainterPath()
path.addRoundedRect(QtCore.QRectF(self.rect()), radius, radius)
try:
mask = QtGui.QRegion(path.toFillPolygon().toPolygon())
self.setMask(mask)
except TypeError: # Required for older versions of Qt
pass
self.animation.start()
示例4: fillImage
# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QRegion [as 别名]
def fillImage(self, pixmap, painter, roi, param, source):
"""Draw image in roi.
"""
x, y, w, h = roi
fillPixmap = QPixmap(param.fillPath)
if not fillPixmap.isNull():
fillPixmap = fillPixmap.scaled(w, h, QtCore.Qt.IgnoreAspectRatio)
mask = self.getMask(pixmap, x, y, w, h, param.shape, None,
QtCore.Qt.white, QtCore.Qt.black)
painter.setClipRegion(QtGui.QRegion(QtGui.QBitmap(mask)))
painter.drawPixmap(x, y, fillPixmap)
painter.setClipping(False)
示例5: setRoundMask
# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QRegion [as 别名]
def setRoundMask(self):
bmp = QPixmap(self.size())
bmp.fill(Qt.white)
p = QPainter(bmp)
p.setRenderHint(QPainter.Antialiasing)
p.setBrush(QBrush(Qt.white))
p.setCompositionMode(QPainter.CompositionMode_Clear)
p.drawRoundedRect(0, 0, self.width(), self.height(), 3, 3)
p.end()
self.setMask(QRegion(QBitmap(bmp)))
示例6: paintEvent
# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QRegion [as 别名]
def paintEvent(self, event): # noqa: N802
"""Called when the widget is being painted."""
# Adjust the buffer size according to the pixel ratio
dpr = self.devicePixelRatioF()
buffer = QPixmap(self.width() * dpr, self.height() * dpr)
buffer.setDevicePixelRatio(dpr)
buffer.fill(Qt.transparent)
painter = QPainter(buffer)
# Paint the server text widget
region = QRegion(
QRect(QPoint(0, 0), self._servers_text_widget.sizeHint())
)
self._servers_text_widget.render(painter, QPoint(0, 0), region)
# Paint the server icon widget
region = QRegion(
QRect(QPoint(0, 0), self._servers_icon_widget.sizeHint())
)
x = self._servers_text_widget.sizeHint().width() + 3
self._servers_icon_widget.render(painter, QPoint(x, 0), region)
# Paint the invites text widget
region = QRegion(
QRect(QPoint(0, 0), self._invites_text_widget.sizeHint())
)
x += self._servers_icon_widget.sizeHint().width() + 3
self._invites_text_widget.render(painter, QPoint(x, 0), region)
# Paint the invites icon widget
region = QRegion(
QRect(QPoint(0, 0), self._invites_icon_widget.sizeHint())
)
x += self._invites_text_widget.sizeHint().width() + 3
self._invites_icon_widget.render(painter, QPoint(x, 0), region)
# Paint the users text widget
region = QRegion(
QRect(QPoint(0, 0), self._users_text_widget.sizeHint())
)
x += self._invites_icon_widget.sizeHint().width() + 3
self._users_text_widget.render(painter, QPoint(x, 0), region)
# Paint the users icon widget
region = QRegion(
QRect(QPoint(0, 0), self._users_icon_widget.sizeHint())
)
x += self._users_text_widget.sizeHint().width() + 3
self._users_icon_widget.render(painter, QPoint(x, 0), region)
painter.end()
painter = QPainter(self)
painter.drawPixmap(event.rect(), buffer, buffer.rect())
painter.end()
示例7: updateInfo
# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QRegion [as 别名]
def updateInfo(self):
if not self.snapshots.busy():
self.prepairExit()
self.qapp.exit(0)
return
paused = tools.processPaused(self.snapshots.pid())
self.btnPause.setVisible(not paused)
self.btnResume.setVisible(paused)
message = self.snapshots.takeSnapshotMessage()
if message is None and self.last_message is None:
message = (0, _('Working...'))
if not message is None:
if message != self.last_message:
self.last_message = message
if self.decode:
message = (message[0], self.decode.log(message[1]))
self.menuStatusMessage.setText('\n'.join(tools.wrapLine(message[1],\
size = 80,\
delimiters = '',\
new_line_indicator = '') \
))
self.status_icon.setToolTip(message[1])
pg = progress.ProgressFile(self.config)
if pg.fileReadable():
pg.load()
percent = pg.intValue('percent')
## disable progressbar in icon until BiT has it's own icon
## fixes bug #902
# if percent != self.progressBar.value():
# self.progressBar.setValue(percent)
# self.progressBar.render(self.pixmap, sourceRegion = QRegion(0, -14, 24, 6), flags = QWidget.RenderFlags(QWidget.DrawChildren))
# self.status_icon.setIcon(QIcon(self.pixmap))
self.menuProgress.setText(' | '.join(self.getMenuProgress(pg)))
self.menuProgress.setVisible(True)
else:
# self.status_icon.setIcon(self.icon.BIT_LOGO)
self.menuProgress.setVisible(False)