當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。