PyQt5在标签中显示动画gif


# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'C:UsersΧρήστοςDesktopPapinhio playerprojectmainui filesMenu 1Sound filesImport sound fileLoading imageloading.ui'
#
# Created by: PyQt5 UI code generator 5.15.0
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again.  Do not edit this file unless you know what you are doing.

from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtGui import QMovie
class Ui_dialog(object):
def setupUi(self, dialog):
dialog.setObjectName("dialog")
dialog.resize(430, 110)
self.horizontalLayout = QtWidgets.QHBoxLayout(dialog)
self.horizontalLayout.setObjectName("horizontalLayout")
spacerItem = QtWidgets.QSpacerItem(197, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.horizontalLayout.addItem(spacerItem)
self.label = QtWidgets.QLabel(dialog)
self.label.setObjectName("label")
self.horizontalLayout.addWidget(self.label)
spacerItem1 = QtWidgets.QSpacerItem(197, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.horizontalLayout.addItem(spacerItem1)
self.movie = QMovie("ajax-loader.gif")
self.label.setText("")
self.label.setMovie(self.movie)
#self.label.setScaledContents(True)
self.movie.start()
self.label.resize(220,19)

self.retranslateUi(dialog)
QtCore.QMetaObject.connectSlotsByName(dialog)
def retranslateUi(self, dialog):
_translate = QtCore.QCoreApplication.translate
dialog.setWindowTitle(_translate("dialog", "Εισαγωγή αρχείου ήχου"))
#self.label.setText(_translate("dialog", "123456789101112131415"))
#import main_icons_rc

if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
dialog = QtWidgets.QDialog()
ui = Ui_dialog()
ui.setupUi(dialog)
dialog.show()
sys.exit(app.exec_())

上面的代码在ubuntu 20.04中工作,但它在Windows 10中没有出现任何东西(只有窗口,带有标题和?,X按钮(。

在Ubuntu中,我有python3.6在Windows 10中,我有python3.8

怎么了?

if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
app.addLibraryPath(r"C:UsersΧρήστοςAppDataLocalProgramsPythonPython38Libsite-packagespyqt5_toolsQtplugins")
dialog = QtWidgets.QDialog()
ui = Ui_dialog()
ui.setupUi(dialog)
dialog.show()
sys.exit(app.exec_())

我必须导入图像库才能工作!!!

相关内容

  • 没有找到相关文章

最新更新