當前位置: 首頁>>代碼示例>>Python>>正文


Python QtGui.QRegion方法代碼示例

本文整理匯總了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) 
開發者ID:BasioMeusPuga,項目名稱:Lector,代碼行數:40,代碼來源:definitionsdialog.py

示例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) 
開發者ID:BasioMeusPuga,項目名稱:Lector,代碼行數:42,代碼來源:metadatadialog.py

示例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() 
開發者ID:BasioMeusPuga,項目名稱:Lector,代碼行數:32,代碼來源:dockwidgets.py

示例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) 
開發者ID:xsyann,項目名稱:detection,代碼行數:14,代碼來源:detection.py

示例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))) 
開發者ID:dragondjf,項目名稱:QMusic,代碼行數:12,代碼來源:dquickview.py

示例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() 
開發者ID:IDArlingTeam,項目名稱:IDArling,代碼行數:52,代碼來源:widget.py

示例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) 
開發者ID:bit-team,項目名稱:backintime,代碼行數:44,代碼來源:qtsystrayicon.py


注:本文中的PyQt5.QtGui.QRegion方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。