agovela

Untitled

Sep 9th, 2015
547
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. import PySide.QtCore as qc
  2. import PySide.QtGui as qg
  3.  
  4.  
  5. class MovieSplashScreen(qg.QSplashScreen):
  6. def __init__(self, movie, parent = None):
  7. movie.jumpToFrame(0)
  8. pixmap = qg.QPixmap(movie.frameRect().size())
  9. qg.QSplashScreen.__init__(self, pixmap)
  10. self.movie = movie
  11.  
  12. class animWidget(qg.QWidget ):
  13. def __init__(self,gifPath,parent = None):
  14. qg.QWidget.__init__(self)
  15. movie = qg.QMovie(gifPath)
  16. self.movie = movie
  17. self.splash = MovieSplashScreen(movie)
  18. self.layout = qg.QHBoxLayout(self)
  19. self.setLayout(self.layout)
  20. self.animGif = qg.QLabel(self)
  21. self.animGif.setMouseTracking(True)
  22. self.animGif.setMovie(movie)
  23. self.layout.addWidget(self.animGif)
  24. self.installEventFilter(self)
  25.  
  26. def eventFilter(self, widget, event):
  27. if event.type() == qc.QEvent.MouseMove:
  28. self.movie.start()
  29.  
  30. elif event.type() == qc.QEvent.Leave:
  31. self.movie.stop()
  32. self.movie.jumpToFrame(0)
  33.  
  34. class Window(qg.QWidget):
  35. def __init__(self,parent = None):
  36. qg.QWidget.__init__(self)
  37. self.w_layout = qg.QVBoxLayout(self)
  38. self.setLayout(self.w_layout)
  39.  
  40.  
  41. if __name__ == '__main__':
  42.  
  43. win = Window()
  44.  
  45. animG = animWidget("d:/cutebunny.gif")
  46. animG.setMouseTracking(True)
  47.  
  48. animG2 = animWidget("d:/sof.gif")
  49. animG2.setMouseTracking(True)
  50.  
  51. win.w_layout.addWidget(animG)
  52. win.w_layout.addWidget(animG2)
  53.  
  54. win.show()
Advertisement
Add Comment
Please, Sign In to add comment