I cleaned up the code a bit...I just realized since I hadn't restarted maya for a while, the code was not working because I moved a class around. Still stuck though.
Thanks! code: from PySide import QtGui from PySide import QtCore import PySide.QtCore as qc import PySide.QtGui as qg from PySide.QtCore import * from PySide.QtGui import * class MovieSplashScreen(QSplashScreen): def __init__(self, movie, parent = None): movie.jumpToFrame(0) pixmap = QPixmap(movie.frameRect().size()) QSplashScreen.__init__(self, pixmap) self.movie = movie self.movie.frameChanged.connect(self.repaint) def showEvent(self, event): self.movie.start() def hideEvent(self, event): self.movie.stop() def paintEvent(self, event): painter = QPainter(self) pixmap = self.movie.currentPixmap() self.setMask(pixmap.mask()) painter.drawPixmap(0, 0, pixmap) def sizeHint(self): return self.movie.scaledSize() class Window(QtGui.QWidget): class animWidget(QtGui.QWidget): mStart = Signal() mStop = Signal() START = Signal () zeros = 0 def __init__(self,parent=None): QtGui.QWidget.__init__(self) self._last_index = QtCore.QPersistentModelIndex() self.installEventFilter(self) def eventFilter(self, widget, event): if event.type() == QtCore.QEvent.MouseMove: print "Starting..." #self.mStart.emit() #self.startMovie() self.START.emit() self.emit(SIGNAL("mStart")) self.emit(SIGNAL("START")) elif event.type() == QtCore.QEvent.Leave: print "Pausing" self.mStop.emit() return QtGui.QTableWidget.eventFilter(self, widget, event) def startMovie(self,*args): print "zzz" #self.start() def __init__(self, rows, columns): QtGui.QWidget.__init__(self) self.anim = self.animWidget(self) self.anim.setMouseTracking(True) self.animLayout = QtGui.QHBoxLayout() self.anim.setLayout (self.animLayout) layout = QtGui.QVBoxLayout(self) movie = qg.QMovie("d:/cutebunny.gif") self.movie = movie splash = MovieSplashScreen(movie) self.animGif = qg.QLabel(self) self.animGif.setMovie(movie) #self.movie.start() self.animLayout.addWidget(self.animGif) layout.addWidget(self.anim) #self.anim.connect(SIGNAL("START"), self.startMovieX) #self.anim.connect(SIGNAL("mSTART"), self.startMovieX) def startMovieX(self,*args): print "xxx" #self.movie.start() if __name__ == '__main__': import sys #app = QtGui.QApplication(sys.argv) window = Window(6, 3) window.setGeometry(500, 300, 350, 250) window.show() #sys.exit(app.exec_()) On Tuesday, September 8, 2015 at 9:36:17 PM UTC-7, Antonio Govela wrote: > > Hi, I'm still trying to wrap my head around events and trying to start an > animated gif 'splashed' on a widget. > I can manage to detect when the mouse hovers in and out to display a start > and stop but I can't seem to find how to trigger the movie.start() action. > > > I mashed up bits of code form other sites to display a window with an > animated gif. > > Any clues would be helpful... > here's the code (any animated gif should work) > > > > from PySide import QtGui, QtCore > import PySide.QtCore as qc > import PySide.QtGui as qg > > from PySide.QtCore import Signal,Slot > > import sys, time > from PySide.QtCore import Qt, QTimer > from PySide.QtGui import * > > > import sys > from PySide.QtCore import * > from PySide.QtGui import * > > > class Window(QtGui.QWidget): > class MovieSplashScreen(QSplashScreen): > > def __init__(self, movie, parent = None): > movie.jumpToFrame(0) > pixmap = QPixmap(movie.frameRect().size()) > QSplashScreen.__init__(self, pixmap) > self.movie = movie > self.movie.frameChanged.connect(self.repaint) > def showEvent(self, event): > self.movie.start() > def hideEvent(self, event): > self.movie.stop() > def paintEvent(self, event): > painter = QPainter(self) > pixmap = self.movie.currentPixmap() > self.setMask(pixmap.mask()) > painter.drawPixmap(0, 0, pixmap) > def sizeHint(self): > return self.movie.scaledSize() > class animWidget(QtGui.QWidget): > mStart = Signal() > mStop = Signal() > zeros = 0 > def __init__(self,parent=None): > QtGui.QWidget.__init__(self) > self._last_index = QtCore.QPersistentModelIndex() > self.installEventFilter(self) > def eventFilter(self, widget, event): > if event.type() == QtCore.QEvent.MouseMove: > print "Starting..." > self.mStart.emit() > self.startMovie() > self.emit(SIGNAL("mStart")) > > elif event.type() == QtCore.QEvent.Leave: > print "Pausing" > self.mStop.emit() > return QtGui.QTableWidget.eventFilter(self, widget, event) > def startMovie(self,*args): > print "xxx" > #self.start() > > def __init__(self, rows, columns): > QtGui.QWidget.__init__(self) > self.anim = self.animWidget(self) > self.anim.setMouseTracking(True) > self.animLayout = QtGui.QHBoxLayout() > self.anim.setLayout (self.animLayout) > layout = QtGui.QVBoxLayout(self) > movie = qg.QMovie("d:/cutebunny.gif") > self.movie = movie > splash = MovieSplashScreen(movie) > self.animGif = qg.QLabel(self) > self.animGif.setMovie(movie) > #self.movie.start() > self.animLayout.addWidget(self.animGif) > layout.addWidget(self.anim) > #self.movie.connect(SIGNAL("START"), self.startMovie) > #self.movie.connect(SIGNAL("mSTART"), self.startMovie) > > > > > > > > > > > if __name__ == '__main__': > > import sys > #app = QtGui.QApplication(sys.argv) > window = Window(6, 3) > window.setGeometry(500, 300, 350, 250) > window.show() > > > #sys.exit(app.exec_()) > > > > > > -- You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group. To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/d164c8e5-96c0-4974-806c-5307342f8b86%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.