Python 添加启动屏幕后PyQt4应用程序崩溃
我正在尝试将splashscreen添加到我的PyQt4 GUI应用程序中。代码工作正常,直到我关闭应用程序,使Python崩溃,并显示“Python.exe已停止工作”。这是密码Python 添加启动屏幕后PyQt4应用程序崩溃,python,pyqt4,qsplashscreen,Python,Pyqt4,Qsplashscreen,我正在尝试将splashscreen添加到我的PyQt4 GUI应用程序中。代码工作正常,直到我关闭应用程序,使Python崩溃,并显示“Python.exe已停止工作”。这是密码 if __name__ == "__main__": app = QtGui.QApplication(sys.argv) #Splashscreen movie = QMovie("giphy-downsized.gif") splash = MovieSplashScreen(m
if __name__ == "__main__":
app = QtGui.QApplication(sys.argv)
#Splashscreen
movie = QMovie("giphy-downsized.gif")
splash = MovieSplashScreen(movie)
splash.show()
start = time.time()
while movie.state() == QMovie.Running and time.time() < start + 10:
app.processEvents()
MainWindow = QtGui.QMainWindow()
splash.finish(MainWindow)
movie.stop()
ui = Ui_MainWindow()
ui.setupUi(MainWindow)
MainWindow.show()
splash.close()
sys.exit(app.exec_())
请阅读python回溯——它清楚地说明了问题所在。(注:今后,请不要发布控制台输出的图像。始终将实际文本复制并粘贴到您的问题中)。什么是MovieSplashScreen?您可以显示完整的代码这是MovieSplashScreen类。完整的代码超过700行。
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()