Reputation: 25094
I have a working example of playing a gif, but it isn't looping the GIF. Even i changed movie.setCacheMode(QMovie.CacheAll)
Any Idea? -->Animated Gif
from PyQt4 import QtCore, QtGui
from PyQt4.QtGui import *
from PyQt4.QtCore import *
import sys
class ImagePlayer(QWidget):
def __init__(self, filename, title, parent=None):
QWidget.__init__(self, parent)
# Load the file into a QMovie
self.movie = QMovie(filename, QByteArray(), self)
size = self.movie.scaledSize()
self.setGeometry(200, 200, size.width(), size.height())
self.setWindowTitle(title)
self.movie_screen = QLabel()
# Make label fit the gif
self.movie_screen.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
self.movie_screen.setAlignment(Qt.AlignCenter)
# Create the layout
main_layout = QVBoxLayout()
main_layout.addWidget(self.movie_screen)
self.setLayout(main_layout)
# Add the QMovie object to the label
self.movie.setCacheMode(QMovie.CacheAll)
self.movie.setSpeed(100)
self.movie_screen.setMovie(self.movie)
self.movie.start()
self.movie.loopCount()
if __name__ == "__main__":
gif = "dotGreen.gif"
app = QApplication(sys.argv)
player = ImagePlayer(gif, "was")
player.show()
sys.exit(app.exec_())
Upvotes: 1
Views: 3230
Reputation: 25094
Actually the gif was saved before with the Looping Option play once. So changing it to "Forever" did the trick.
Upvotes: 2