赞
踩
素材 a.gif
PyQt5 装载Gif动画 案例
QMovie
- import sys
-
- from PyQt5.QtCore import Qt, QTimer
- from PyQt5.QtGui import QIcon, QBitmap, QPainter, QPixmap, QCursor, QMovie
- from PyQt5.QtWidgets import QHBoxLayout, QPushButton, QMessageBox, QApplication, QVBoxLayout, QWidget, \
- QLabel, QGridLayout, QLineEdit, QTextEdit, QFormLayout, QComboBox
-
- '''
- PyQt5 装载Gif动画 案例
- QMovie
- '''
-
-
- class LoadingGifDemo(QWidget):
-
- def __init__(self):
- super().__init__()
- self.initUI()
-
- def initUI(self):
- # 设置定位和左上角坐标
- # self.setGeometry(300, 300, 360, 260)
- # 设置窗口标题
- self.setWindowTitle('异形窗口 的演示')
- # 设置窗口图标
- # self.setWindowIcon(QIcon('../web.ico'))
- # self.setWindowFlags(Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint)
- # self.setStyleSheet('''background-color:black; ''')
- self.label = QLabel("",self)
- self.setFixedSize(658,494)
- self.setWindowFlags(Qt.Dialog | Qt.CustomizeWindowHint)
- self.movie = QMovie('a.gif')
- self.label.setMovie(self.movie)
- self.movie.start()
-
- def mousePressEvent(self,event):
- # 左击
- if event.button() == Qt.LeftButton:
-
- print(event.globalPos())
- print(event.pos())
- print(self.pos())
-
- # 右击
- if event.button() == Qt.RightButton:
- self.close()
-
-
- if __name__ == '__main__':
- app = QApplication(sys.argv)
- # 设置应用图标
- app.setWindowIcon(QIcon('../web.ico'))
- w = LoadingGifDemo()
-
- w.show()
- sys.exit(app.exec_())
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。