if __name__ == "__main__":
ui_style = UIStyle().get_style()
app = QtWidgets.QApplication(sys.argv)
# 创建QSplashScreen对象实例
splash = QtWidgets.QSplashScreen(QtGui.QPixmap("UserView/logo.png"))
# 设置画面中的文字的字体
splash.setFont(QFont('Microsoft YaHei UI', 12))
# 显示画面
splash.show()
# 显示信息
splash.showMessage("启动中... 0%", QtCore.Qt.AlignLeft | QtCore.Qt.AlignBottom, QtCore.Qt.white)
time.sleep(1)
splash.showMessage("正在加载样式表...20%", QtCore.Qt.AlignLeft | QtCore.Qt.AlignBottom, QtCore.Qt.white)
if(ui_style=='dark'):
app.setStyleSheet(qdarkstyle.load_stylesheet_pyqt5())
time.sleep(1)
splash.showMessage("正在加载样式表...40%", QtCore.Qt.AlignLeft | QtCore.Qt.AlignBottom, QtCore.Qt.white)
time.sleep(1)
splash.showMessage("正在加载数据库配置...60%", QtCore.Qt.AlignLeft | QtCore.Qt.AlignBottom, QtCore.Qt.white)
time.sleep(1)
splash.showMessage("正在测试数据库连接...80%", QtCore.Qt.AlignLeft | QtCore.Qt.AlignBottom, QtCore.Qt.white)
conn = GetMysqlConnection().get_connection()
if(conn!=0):
conn.close()
splash.showMessage("正在测试数据库连接...Success", QtCore.Qt.AlignLeft | QtCore.Qt.AlignBottom, QtCore.Qt.white)
else:
splash.showMessage("正在测试数据库连接...faild", QtCore.Qt.AlignLeft | QtCore.Qt.AlignBottom, QtCore.Qt.white)
time.sleep(2)
splash.showMessage("启动中...100%", QtCore.Qt.AlignLeft | QtCore.Qt.AlignBottom, QtCore.Qt.white)
time.sleep(2)
ui = MainWindow()
ui.show()
# 当主界面显示后销毁启动画面
splash.finish(ui)
sys.exit(app.exec_())
# 实现这个函数
def closeEvent(self, QCloseEvent):
# 使用QMessageBox提示
reply = QMessageBox.warning(self, "温馨提示", "即将退出, 确定?", QMessageBox.Yes|QMessageBox.No, QMessageBox.No)
if(reply == QMessageBox.Yes):
QCloseEvent.accept()
if(reply==QMessageBox.No):
QCloseEvent.ignore()
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。