-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
94 lines (79 loc) · 3.3 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
import os
import sys
from PyQt5 import QtGui, QtCore
from PyQt5.QtGui import QPixmap, QIcon
from PyQt5.QtWidgets import QApplication, QWidget, QSplashScreen, QMessageBox
import gui_main
from config import base_path
# from qt_material import apply_stylesheet
class QWidgetCl(QWidget):
def __init__(self, parent=None):
super(QWidgetCl, self).__init__(parent)
def closeEvent(self, e):
self.box = QMessageBox(QMessageBox.Warning, "提示信息", "请确认是否关闭软件?")
icon = QIcon()
icon.addPixmap(QPixmap(os.path.join(base_path, 'img', 'ict-logo.ico')), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.box.setWindowIcon(icon)
qyes = self.box.addButton(self.tr("是"), QMessageBox.YesRole)
qno = self.box.addButton(self.tr("否"), QMessageBox.NoRole)
self.box.exec_()
if self.box.clickedButton() == qyes:
e.accept()
return super(QWidgetCl, self).closeEvent(e)
else:
e.ignore()
def password_UI():
pwapp = QApplication(sys.argv)
MainWindow = QWidget()
MainWindow.setWindowTitle("ICT预审表 v0.94")
MainWindow.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint |
QtCore.Qt.WindowCloseButtonHint | QtCore.Qt.WindowMinimizeButtonHint)
icon = QIcon()
icon.addPixmap(QPixmap(os.path.join(base_path, 'img', 'ict-logo.ico')), QtGui.QIcon.Normal, QtGui.QIcon.Off)
MainWindow.setWindowIcon(icon)
w = pwapp.desktop().screenGeometry().width()
h = pwapp.desktop().screenGeometry().height()
pw = gui_main.pwdUI(MainWindow)
pw.resize(w//3.8, h//18)
pw.setFixedSize(pw.width(), pw.height())
pw.pwd.setFixedWidth(w//7)
MainWindow.resize(w//3.8, h//18)
MainWindow.setFixedSize(MainWindow.width(), MainWindow.height())
MainWindow.show()
# return 1
return pwapp.exec()
def main_exec(start_wait=True):
app = QApplication(sys.argv)
w = app.desktop().screenGeometry().width()
h = app.desktop().screenGeometry().height()
# import ctypes
# ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID("myappid")
if start_wait:
splash = QSplashScreen(QPixmap(os.path.join(base_path, 'img', 'start.svg'))) # 启动界面图片地址
splash.show() # 展示启动图片
splash.showMessage("<h1><font color='black'>启动中</font></h1>",
QtCore.Qt.AlignTop | QtCore.Qt.AlignCenter, QtCore.Qt.black)
app.processEvents()
# apply_stylesheet(app, theme='light_amber.xml')
MainWindow = QWidgetCl()
icon = QIcon()
icon.addPixmap(QPixmap(os.path.join(base_path, 'img', 'ict-logo.ico')), QtGui.QIcon.Normal, QtGui.QIcon.Off)
MainWindow.setWindowIcon(icon)
# MainWindow.setFont(QtGui.QFont("ZYSong18030", 12)) # 全局字体
# MainWindow.setWindowFlags(QtCore.Qt.WindowCloseButtonHint|QtCore.Qt.WindowMinimizeButtonHint|QtCore.Qt.WindowMaximizeButtonHint)
ui = gui_main.UiForm(MainWindow, w, h)
ui.setupUi(MainWindow)
MainWindow.show()
if start_wait:
splash.finish(MainWindow)
return app.exec_()
def while_reset():
exit_code = main_exec(True)
while exit_code == 11950:
exit_code = main_exec(False)
sys.exit(0)
if __name__ == '__main__':
if password_UI() == 1:
while_reset()
else:
sys.exit(0)