您好,登錄后才能下訂單哦!
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進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。