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


Python QtGui.QMovie方法代码示例

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


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

示例1: onFinished

# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QMovie [as 别名]
def onFinished(self):
        """图片下载完成
        """
        self.loadingTimer.stop()
        self.pradius = 0
        reply = self.sender()

        if self.isGif:
            self._movie = QMovie(reply, b'gif', self)
            if self._movie.isValid():
                self._movie.frameChanged.connect(self._resizeGifPixmap)
                self._movie.start()
        else:
            data = reply.readAll().data()
            reply.deleteLater()
            del reply
            self._pixmap.loadFromData(data)
            if self._pixmap.isNull():
                self._pixmap = QPixmap(self.size())
                self._pixmap.fill(QColor(204, 204, 204))
            self._resizePixmap() 
开发者ID:PyQt5,项目名称:CustomWidgets,代码行数:23,代码来源:CAvatar.py

示例2: _doDownloadImage

# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QMovie [as 别名]
def _doDownloadImage(self, url):
        # 下载图片并添加到界面
        async with self.session.get(url) as resp:
            data = await resp.read()
            if not data:
                print('下载失败: ', url)
                return
            path = os.path.join('tmp', os.path.basename(url))
            with open(path, 'wb') as fp:
                fp.write(data)
            item = QListWidgetItem(url, self.listWidget)
            image = QPixmap(path)
            item.setSizeHint(image.size())
            label = QLabel(self.listWidget)
            label.setPixmap(image)
            if path.endswith('.gif'):  # 可能是动态图
                label.setMovie(QMovie(path))
            self.listWidget.setItemWidget(item, label)
            self.listWidget.scrollToBottom() 
开发者ID:PyQt5,项目名称:PyQt,代码行数:21,代码来源:窗口配合异步Http.py

示例3: __init__

# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QMovie [as 别名]
def __init__(self, gui):
        super(SystemTrayIcon, self).__init__()
        self.gui = gui

        tray_icon_path = resource(settings["application"]["tray_icon"])
        self.app_pixmap = QPixmap(tray_icon_path)
        self.app_icon = QIcon(tray_icon_path)
        self.setIcon(self.app_icon)

        self.menu = Menu(self.gui)
        self.setContextMenu(self.menu)
        self.activated.connect(self.on_click)

        self.messageClicked.connect(self.gui.show_main_window)

        self.animation = QMovie()
        self.animation.setFileName(
            resource(settings["application"]["tray_icon_sync"])
        )
        self.animation.updated.connect(self.update)
        self.animation.setCacheMode(True) 
开发者ID:gridsync,项目名称:gridsync,代码行数:23,代码来源:systray.py

示例4: __init__

# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QMovie [as 别名]
def __init__(self, text="Loading..."):
        super(MessageBox, self).__init__()
        self.setWindowTitle("Messages")

        self.setLayout(QtWidgets.QHBoxLayout())
        self._layout = self.layout()

        self._gif = QtWidgets.QLabel()
        movie = QtGui.QMovie("loading.gif")
        self._gif.setMovie(movie)
        movie.start()
        self._layout.addWidget(self._gif)

        self._message = QtWidgets.QLabel()
        self._message.setText(text)
        self._layout.addWidget(self._message)
        self.setObjectName('Message_Window') 
开发者ID:nccgroup,项目名称:binja_dynamics,代码行数:19,代码来源:__init__.py

示例5: __init__

# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QMovie [as 别名]
def __init__(self, labelText, cancellable=True, parent=None):
        super(SpinnerWidget, self).__init__(parent=parent)
        self.setupUi(self)
        self.movie = QtGui.QMovie(":qrc/rotator-32.gif")
        self.icon.setMovie(self.movie)
        self.originalLabelText = labelText
        self.label.setText(labelText)
        if cancellable:
            self.cancelButton.clicked.connect(self.cancelled.emit)
        else:
            self.cancelButton.hide()
        self.hide() 
开发者ID:iris-edu,项目名称:pyweed,代码行数:14,代码来源:SpinnerWidget.py

示例6: get_zip_graphic

# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QMovie [as 别名]
def get_zip_graphic(self, name):
        if os.path.exists("ecu.zip"):
            zf = zipfile.ZipFile("ecu.zip", "r")
            zname = "graphics/" + name + ".gif"
            if not zname in zf.namelist():
                zname = "graphics/" + name + ".GIF"
            if zname in zf.namelist():
                ba = core.QByteArray(zf.read(zname))
                self.buffer = core.QBuffer()
                self.buffer.setData(ba)
                self.buffer.open(core.QIODevice.ReadOnly)
                self.img = gui.QMovie(self.buffer, 'GIF') 
开发者ID:cedricp,项目名称:ddt4all,代码行数:14,代码来源:displaymod.py

示例7: initXML

# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QMovie [as 别名]
def initXML(self, xmldata):
        text = xmldata.getAttribute("Text")
        color = xmldata.getAttribute("Color")
        alignment = xmldata.getAttribute("Alignment")

        if text.startswith("::pic:"):
            self.setScaledContents(True)
            img_name = text.replace("::pic:", "").replace("\\", "/")
            self.get_zip_graphic(img_name)
            if self.img is None:
                imgname = os.path.join(options.graphics_dir, img_name) + ".gif"
                if not os.path.exists(imgname):
                    imgname = os.path.join(options.graphics_dir, img_name) + ".GIF"
                self.img = gui.QMovie(imgname)
            self.setMovie(self.img)
            self.img.start()
        else:
            self.setText(text)

        rect = getRectangleXML(getChildNodesByName(xmldata, "Rectangle")[0], self.uiscale)
        qfnt = getXMLFont(xmldata, self.uiscale)

        self.area = rect['width'] * rect['height']
        self.setFont(qfnt)
        self.resize(rect['width'], rect['height'])
        self.setStyleSheet("background: %s; color: %s" % (colorConvert(color), getFontColor(xmldata)))

        self.move(rect['left'], rect['top'])
        if alignment == '2':
            self.setAlignment(core.Qt.AlignHCenter)
        elif alignment == '1':
            self.setAlignment(core.Qt.AlignRight)
        else:
            self.setAlignment(core.Qt.AlignLeft) 
开发者ID:cedricp,项目名称:ddt4all,代码行数:36,代码来源:displaymod.py

示例8: initJson

# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QMovie [as 别名]
def initJson(self, jsdata):
        text = jsdata['text']
        color = jsdata['color']
        alignment = jsdata['alignment']
        fontcolor = jsdata['fontcolor']

        rect = jsdata['bbox']
        self.area = rect['width'] * rect['height']
        qfnt = jsonFont(jsdata['font'], self.uiscale)

        self.ismovable = True
        self.setFont(qfnt)

        if text.startswith("::pic:"):
            self.setScaledContents(True)
            img_name = text.replace("::pic:", "").replace("\\", "/")
            self.get_zip_graphic(img_name)
            if self.img is None:
                imgname = os.path.join(options.graphics_dir, img_name) + ".gif"
                if not os.path.exists(imgname):
                    imgname = os.path.join(options.graphics_dir, img_name) + ".GIF"
                self.img = gui.QMovie(imgname)
            self.setMovie(self.img)
            self.img.start()
        else:
            self.setText(text)

        self.resize(rect['width'] / self.uiscale, rect['height'] / self.uiscale)
        self.setStyleSheet("background: %s; color: %s" % (color, fontcolor))

        self.move(rect['left'] / self.uiscale, rect['top'] / self.uiscale)
        if alignment == '2':
            self.setAlignment(core.Qt.AlignHCenter)
        elif alignment == '1':
            self.setAlignment(core.Qt.AlignRight)
        else:
            self.setAlignment(core.Qt.AlignLeft)

        self.jsondata = jsdata 
开发者ID:cedricp,项目名称:ddt4all,代码行数:41,代码来源:displaymod.py

示例9: _get

# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QMovie [as 别名]
def _get(self, url):
        """设置图片或者请求网络图片
        :param url:
        """
        if not url:
            self.onError('')
            return
        if url.startswith('http') and not self.loadingTimer.isActive():
            url = QUrl(url)
            request = QNetworkRequest(url)
            request.setHeader(QNetworkRequest.UserAgentHeader, b'CAvatar')
            request.setRawHeader(b'Author', b'Irony')
            request.setAttribute(
                QNetworkRequest.FollowRedirectsAttribute, True)
            if qApp._network.cache():
                request.setAttribute(
                    QNetworkRequest.CacheLoadControlAttribute, QNetworkRequest.PreferNetwork)
                request.setAttribute(
                    QNetworkRequest.CacheSaveControlAttribute, True)
            reply = qApp._network.get(request)
            self.pradius = 0
            self.loadingTimer.start(50)  # 显示进度动画
            reply.finished.connect(self.onFinished)
            reply.error.connect(self.onError)
            return
        self.pradius = 0
        if os.path.exists(url) and os.path.isfile(url):
            if self.isGif:
                self._movie = QMovie(url, parent=self)
                if self._movie.isValid():
                    self._movie.frameChanged.connect(self._resizeGifPixmap)
                    self._movie.start()
            else:
                self._pixmap = QPixmap(url)
                self._resizePixmap()
        else:
            self.onError('') 
开发者ID:PyQt5,项目名称:CustomWidgets,代码行数:39,代码来源:CAvatar.py

示例10: egg

# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QMovie [as 别名]
def egg(self):
        self.kpos = 0
        movie = QMovie(":/action/media/media.qrc")
        self.ui.label.setText(None)
        self.ui.label.setMovie(movie)
        movie.start()
        self.setStyleSheet("QDialog { background-color: red; }") 
开发者ID:TuringApp,项目名称:Turing,代码行数:9,代码来源:about.py

示例11: __init__

# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QMovie [as 别名]
def __init__(self, filename, parent=None):
        QtWidgets.QWidget.__init__(self, parent)
        self.movie = QtGui.QMovie(filename)
        self.movie_screen = QtWidgets.QLabel()
        self.movie_screen.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        main_layout = QtWidgets.QVBoxLayout()
        main_layout.addWidget(self.movie_screen)
        self.setLayout(main_layout)
        self.movie.setCacheMode(QtGui.QMovie.CacheAll)
        self.movie.setSpeed(100)
        self.movie_screen.setMovie(self.movie)
        self.movie.start() 
开发者ID:GoVanguard,项目名称:legion,代码行数:14,代码来源:ancillaryDialog.py

示例12: __init__

# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QMovie [as 别名]
def __init__(self, *args, **kwargs):
        super(ImageView, self).__init__(*args, **kwargs)
        self.resize(800, 600)
        layout = QHBoxLayout(self)

        # 从文件加载图片
        layout.addWidget(QLabel(self, pixmap=QPixmap("Data/head.jpg")))

        # QResource 参考 http://doc.qt.io/qt-5/resources.html

        # 从资源文件中加载1  from py file
        # 转换命令pyrcc5 res.qrc -o res_rc.py
        # 这种方式是从通过pyrcc5转换res.qrc为res_rc.py文件,可以直接import加载
        # 此时可以通过路径:/images/head.jpg来访问
        layout.addWidget(QLabel(self, pixmap=QPixmap(":/images/head.jpg")))

        # 从二进制资源文件res.rcc中加载
        # 转换命令tools/rcc.exe -binary res2.qrc -o res.rcc
        # 这里把资源前缀修改下(/myfile),见res2.qrc文件
        # 此时需要注册
        QResource.registerResource("Data/res.rcc")
        # 注意前缀
        layout.addWidget(
            QLabel(self, pixmap=QPixmap(":/myfile/images/head.jpg")))

        # 从xpm数组中加载
        # 通过工具tools/Image2XPM.exe来转换
        # 这里把转换的xpm数组直接放到py文件中当做一个变量
        # 见xpmres.py中的image_head
        layout.addWidget(QLabel(self, pixmap=QPixmap(image_head)))

        # 加载gif图片
        movie = QMovie("Data/loading.gif")
        label = QLabel(self)
        label.setMovie(movie)
        layout.addWidget(label)
        movie.start() 
开发者ID:PyQt5,项目名称:PyQt,代码行数:39,代码来源:ShowImage.py

示例13: __init__

# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QMovie [as 别名]
def __init__(self, *args, **kwargs):
        super(LoadingWidget, self).__init__(*args, **kwargs)
        self.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
        self._movie = QMovie("loading.gif")
        self.setMovie(self._movie) 
开发者ID:PyQt5,项目名称:PyQt,代码行数:7,代码来源:ChatWidget.py

示例14: __init__

# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QMovie [as 别名]
def __init__(self, *args, **kwargs):
        super(GifSplashScreen, self).__init__(*args, **kwargs)
        self.movie = QMovie('Data/splash.gif')
        self.movie.frameChanged.connect(self.onFrameChanged)
        self.movie.start() 
开发者ID:PyQt5,项目名称:PyQt,代码行数:7,代码来源:GifSplashScreen.py

示例15: __init__

# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QMovie [as 别名]
def __init__(self, parent=None):
        super(Delegate, self).__init__(parent=None)
        self.parent = parent
        self.waiting_movie = QMovie(resource("waiting.gif"))
        self.waiting_movie.setCacheMode(True)
        self.waiting_movie.frameChanged.connect(self.on_frame_changed)
        self.sync_movie = QMovie(resource("sync.gif"))
        self.sync_movie.setCacheMode(True)
        self.sync_movie.frameChanged.connect(self.on_frame_changed) 
开发者ID:gridsync,项目名称:gridsync,代码行数:11,代码来源:view.py


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