在 PyQt5 中创建启动屏幕

2023-12-06

我想创建一个启动画面PyQt5 using Python。我搜索过,但发现Pyqt4我不明白PyQt4所以在这种情况下帮助我我将不胜感激

pyqt 中的启动画面


我喜欢在加载主小部件之前将其添加到稍微淡出的位置 - 请注意,这仅对显示徽标有用,如果您的应用程序加载时间较长,您可以使用启动屏幕,例如@S. Nick已显示在显示闪屏时允许加载时间:

from PyQt5 import QtGui, QtCore, QtWidgets
import time

if __name__ == '__main__':
    app = QtWidgets.QApplication([])
    # Create splashscreen
    splash_pix = QtGui.QPixmap('picture.png')
    splash = QtWidgets.QSplashScreen(splash_pix, QtCore.Qt.WindowStaysOnTopHint)
    # add fade to splashscreen 
    opaqueness = 0.0
    step = 0.1
    splash.setWindowOpacity(opaqueness)
    splash.show()
    while opaqueness < 1:
        splash.setWindowOpacity(opaqueness)
        time.sleep(step) # Gradually appears
        opaqueness+=step
    time.sleep(1) # hold image on screen for a while
    splash.close() # close the splash screen
    #widget = YourWidget()
    #widget.show() # This is where you'd run the normal application
    app.exec_()
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

在 PyQt5 中创建启动屏幕 的相关文章

随机推荐