Animation PySide:在QSplashScreen中放置/移动动画QMovie GIF
我很难让它工作。我希望能够在我的QSPLASH屏幕上的特定位置放置动画GIF GIF必须使用多处理和onNextFrame方法设置动画,以便在初始加载期间播放(否则在第一帧时会冻结) 我尝试过在任何地方插入self.move(500500),但没有任何效果(很好,还不够好)。现在,GIF将在我想要的位置播放,但它将在下一帧弹回到屏幕中心,然后弹回到我想要的位置,等等。在每个可能的位置插入移动方法并没有解决这个问题 代码如下:Animation PySide:在QSplashScreen中放置/移动动画QMovie GIF,animation,pyside,gif,Animation,Pyside,Gif,我很难让它工作。我希望能够在我的QSPLASH屏幕上的特定位置放置动画GIF GIF必须使用多处理和onNextFrame方法设置动画,以便在初始加载期间播放(否则在第一帧时会冻结) 我尝试过在任何地方插入self.move(500500),但没有任何效果(很好,还不够好)。现在,GIF将在我想要的位置播放,但它将在下一帧弹回到屏幕中心,然后弹回到我想要的位置,等等。在每个可能的位置插入移动方法并没有解决这个问题 代码如下: from PySide import QtCore from PySi
from PySide import QtCore
from PySide import QtGui
from multiprocessing import Pool
class Form(QtGui.QDialog):
def __init__(self, parent=None):
super(Form, self).__init__(parent)
self.browser = QtGui.QTextBrowser()
self.setWindowTitle('Just a dialog')
self.move(500,500)
class MySplashScreen(QtGui.QSplashScreen):
def __init__(self, animation, flags):
# run event dispatching in another thread
QtGui.QSplashScreen.__init__(self, QtGui.QPixmap(), flags)
self.movie = QtGui.QMovie(animation)
self.movie.frameChanged.connect(self.onNextFrame)
#self.connect(self.movie, SIGNAL('frameChanged(int)'), SLOT('onNextFrame()'))
self.movie.start()
self.move(500, 500)
def onNextFrame(self):
pixmap = self.movie.currentPixmap()
self.setPixmap(pixmap)
self.setMask(pixmap.mask())
self.move(500, 500)
# Put your initialization code here
def longInitialization(arg):
time.sleep(args)
return 0
if __name__ == "__main__":
import sys, time
app = QtGui.QApplication(sys.argv)
# Create and display the splash screen
# splash_pix = QPixmap('a.gif')
splash = MySplashScreen('S:\_Studio\_ASSETS\Tutorials\Maya\Coding\Python\_PySide\GIF\dragonGif.gif',
QtCore.Qt.WindowStaysOnTopHint)
# splash.setMask(splash_pix.mask())
#splash.raise_()
splash.move(500, 500)
splash.show()
# this event loop is needed for dispatching of Qt events
initLoop = QtCore.QEventLoop()
pool = Pool(processes=1)
pool.apply_async(longInitialization, [2], callback=lambda exitCode: initLoop.exit(exitCode))
initLoop.exec_()
form = Form()
form.show()
splash.finish(form)
app.exec_()