Splash screen in pyqt

后端 未结 1 1368
心在旅途
心在旅途 2020-12-12 02:44

I want to modify my code to add the splash screen before login dialog is shown(about 2 seconds) .i tried something(changed into comment )but not working .please show me how

相关标签:
1条回答
  • 2020-12-12 03:20

    Use a timer to start the login procedure:

    if __name__ == '__main__':
    
        app = QtGui.QApplication(sys.argv)
    
        splash_pix = QtGui.QPixmap('logo and typeface blue.jpg')
        splash = QtGui.QSplashScreen(splash_pix, QtCore.Qt.WindowStaysOnTopHint)
        splash.show()
    
        def login():
            splash.close()
            if Login().exec_() == QtGui.QDialog.Accepted:
                global window
                window = Main_Window()
                window.show()
            else:
                app.quit()
    
        QtCore.QTimer.singleShot(2000, login)
    
        sys.exit(app.exec_())
    
    0 讨论(0)
提交回复
热议问题