Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import PySide.QtCore as qc
- import PySide.QtGui as qg
- class MovieSplashScreen(qg.QSplashScreen):
- def __init__(self, movie, parent = None):
- movie.jumpToFrame(0)
- pixmap = qg.QPixmap(movie.frameRect().size())
- qg.QSplashScreen.__init__(self, pixmap)
- self.movie = movie
- class animWidget(qg.QWidget ):
- def __init__(self,gifPath,parent = None):
- qg.QWidget.__init__(self)
- movie = qg.QMovie(gifPath)
- self.movie = movie
- self.splash = MovieSplashScreen(movie)
- self.layout = qg.QHBoxLayout(self)
- self.setLayout(self.layout)
- self.animGif = qg.QLabel(self)
- self.animGif.setMouseTracking(True)
- self.animGif.setMovie(movie)
- self.layout.addWidget(self.animGif)
- self.installEventFilter(self)
- def eventFilter(self, widget, event):
- if event.type() == qc.QEvent.MouseMove:
- self.movie.start()
- elif event.type() == qc.QEvent.Leave:
- self.movie.stop()
- self.movie.jumpToFrame(0)
- class Window(qg.QWidget):
- def __init__(self,parent = None):
- qg.QWidget.__init__(self)
- self.w_layout = qg.QVBoxLayout(self)
- self.setLayout(self.w_layout)
- if __name__ == '__main__':
- win = Window()
- animG = animWidget("d:/cutebunny.gif")
- animG.setMouseTracking(True)
- animG2 = animWidget("d:/sof.gif")
- animG2.setMouseTracking(True)
- win.w_layout.addWidget(animG)
- win.w_layout.addWidget(animG2)
- win.show()
Advertisement
Add Comment
Please, Sign In to add comment