当前位置: 首页>>代码示例>>Python>>正文


Python QMovie.setDevice方法代码示例

本文整理汇总了Python中PyQt4.QtGui.QMovie.setDevice方法的典型用法代码示例。如果您正苦于以下问题:Python QMovie.setDevice方法的具体用法?Python QMovie.setDevice怎么用?Python QMovie.setDevice使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyQt4.QtGui.QMovie的用法示例。


在下文中一共展示了QMovie.setDevice方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Widget

# 需要导入模块: from PyQt4.QtGui import QMovie [as 别名]
# 或者: from PyQt4.QtGui.QMovie import setDevice [as 别名]
class Widget(QWidget):
    def __init__(self):
        QWidget.__init__(self)
        self.tray = Tray(self)
        self.setMinimumSize(QSize(320, 200))
        self.setWindowFlags(Qt.Popup|Qt.FramelessWindowHint)
        self.verticalLayout = QVBoxLayout(self)
        self.verticalLayout.setMargin(1)

        self.text = QTextBrowser(self)
        self.text.setReadOnly(True)
        self.text.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.text.setOpenExternalLinks(True)
        self.verticalLayout.addWidget(self.text)
        self.text.textChanged.connect(self.on_text_changed)
        self.notify = Notify(self)

        self.movie = QMovie()
        dev = QBuffer()
        dev.setData(QByteArray.fromBase64(CHECK_IMAGE))
        dev.open(QBuffer.ReadOnly)
        dev.setParent(self.movie)
        self.movie.setDevice(dev)
        self.movie.frameChanged.connect(self.on_frame_changed)

        self.realized = False
        self.show()

    def showEvent(self, event):
        if not self.realized:
            self.realized = True
            event.ignore()
        x, y = self.get_position()
        self.move(x, y)

    def keyPressEvent(self, event):
        if event.key() == Qt.Key_Escape:
            self.hide()

    def get_position(self, size=None):
        if not size: size = self.size()
        tray = self.tray.geometry()
        screen = QApplication.desktop().availableGeometry()
        if tray.left() < screen.left():
            x = screen.left()
            y = screen.height() - size.height()
        elif tray.right() > screen.right():
            x = screen.width() - size.width()
            y = min(screen.height() - size.height(), tray.top())
        elif tray.top() < screen.top():
            x = min(screen.width() - size.width(), tray.left())
            y = screen.top()
        elif tray.bottom() > screen.bottom():
            x = min(screen.width() - size.width(), tray.left())
            y = screen.height() - size.height()
        return x, y

    def on_frame_changed(self):
        self.tray.setIcon(QIcon(self.movie.currentPixmap()))

    def on_text_changed(self):
        if self.text.toPlainText():
            screen = QApplication.desktop().availableGeometry()
            height = self.text.document().size().height()
            if height <= screen.height():
                self.setMinimumHeight(height)
                x, y = self.get_position()
                self.move(x, y)
开发者ID:gen2brain,项目名称:gmailcheck,代码行数:70,代码来源:gmailcheck.py


注:本文中的PyQt4.QtGui.QMovie.setDevice方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。