import sys from PyQt4 import QtGui, QtCore from PyQt4.QtGui import QLabel app = QtGui.QApplication(sys.argv) label = QLabel() label.setWindowFlags(QtCore.Qt.FramelessWindowHint) # 无边框 label.setAttribute(QtCore.Qt.WA_TranslucentBackground) # 背景透明 # 打开gif文件 movie = QtGui.QMovie("./icon/waiting.gif") # 设置cacheMode为CacheAll时表示gif无限循环,注意此时loopCount()返回-1 movie.setCacheMode(QtGui.QMovie.CacheAll) # 播放速度 movie.setSpeed(100) label.setMovie(movie) # 开始播放,对应的是movie.start() movie.start() label.show() sys.exit(app.exec_())
效果如下: