Skip to content

Instantly share code, notes, and snippets.

@csaez
Forked from Svenito/ImagePlayer.py
Created July 6, 2013 11:28
Show Gist options
  • Save csaez/5939639 to your computer and use it in GitHub Desktop.
Save csaez/5939639 to your computer and use it in GitHub Desktop.
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()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment