forked from ycdxsb/LibraryManageDesktopApp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMainWindow.py
106 lines (99 loc) · 4.2 KB
/
MainWindow.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
95
96
97
98
99
100
101
102
103
104
105
106
import sys
from PyQt5.QtWidgets import *
from PyQt5.QtGui import QIcon, QFont
from PyQt5.QtCore import *
import qdarkstyle
from SignIn import SignInWidget
from SignUp import SignUpWidget
import sip
from AdminHome import AdminHome
from StudentHome import StudentHome
from changePasswordDialog import changePasswordDialog
class Main(QMainWindow):
def __init__(self, parent=None):
super(Main, self).__init__(parent)
self.layout = QHBoxLayout()
self.widget = SignInWidget()
self.resize(900, 600)
self.setWindowTitle("欢迎登陆图书馆管理系统")
self.setCentralWidget(self.widget)
bar = self.menuBar()
self.Menu = bar.addMenu("菜单栏")
self.signUpAction = QAction("注册", self)
self.changePasswordAction =QAction("修改密码",self)
self.signInAction = QAction("登录", self)
self.quitSignInAction = QAction("退出登录", self)
self.quitAction = QAction("退出", self)
self.Menu.addAction(self.signUpAction)
self.Menu.addAction(self.changePasswordAction)
self.Menu.addAction(self.signInAction)
self.Menu.addAction(self.quitSignInAction)
self.Menu.addAction(self.quitAction)
self.signUpAction.setEnabled(True)
self.changePasswordAction.setEnabled(True)
self.signInAction.setEnabled(False)
self.quitSignInAction.setEnabled(False)
self.widget.is_admin_signal.connect(self.adminSignIn)
self.widget.is_student_signal[str].connect(self.studentSignIn)
self.Menu.triggered[QAction].connect(self.menuTriggered)
def adminSignIn(self):
sip.delete(self.widget)
self.widget = AdminHome()
self.setCentralWidget(self.widget)
self.changePasswordAction.setEnabled(False)
self.signUpAction.setEnabled(True)
self.signInAction.setEnabled(False)
self.quitSignInAction.setEnabled(True)
def studentSignIn(self, studentId):
sip.delete(self.widget)
self.widget = StudentHome(studentId)
self.setCentralWidget(self.widget)
self.changePasswordAction.setEnabled(False)
self.signUpAction.setEnabled(True)
self.signInAction.setEnabled(False)
self.quitSignInAction.setEnabled(True)
def menuTriggered(self, q):
if(q.text()=="修改密码"):
changePsdDialog=changePasswordDialog(self)
changePsdDialog.show()
changePsdDialog.exec_()
if (q.text() == "注册"):
sip.delete(self.widget)
self.widget = SignUpWidget()
self.setCentralWidget(self.widget)
self.widget.student_signup_signal[str].connect(self.studentSignIn)
self.signUpAction.setEnabled(False)
self.changePasswordAction.setEnabled(True)
self.signInAction.setEnabled(True)
self.quitSignInAction.setEnabled(False)
if (q.text() == "退出登录"):
sip.delete(self.widget)
self.widget = SignInWidget()
self.setCentralWidget(self.widget)
self.widget.is_admin_signal.connect(self.adminSignIn)
self.widget.is_student_signal[str].connect(self.studentSignIn)
self.signUpAction.setEnabled(True)
self.changePasswordAction.setEnabled(True)
self.signInAction.setEnabled(False)
self.quitSignInAction.setEnabled(False)
if (q.text() == "登录"):
sip.delete(self.widget)
self.widget = SignInWidget()
self.setCentralWidget(self.widget)
self.widget.is_admin_signal.connect(self.adminSignIn)
self.widget.is_student_signal[str].connect(self.studentSignIn)
self.signUpAction.setEnabled(True)
self.changePasswordAction.setEnabled(True)
self.signInAction.setEnabled(False)
self.quitSignInAction.setEnabled(False)
if (q.text() == "退出"):
qApp = QApplication.instance()
qApp.quit()
return
if __name__ == "__main__":
app = QApplication(sys.argv)
app.setWindowIcon(QIcon("./images/MainWindow_1.png"))
app.setStyleSheet(qdarkstyle.load_stylesheet_pyqt5())
mainMindow = Main()
mainMindow.show()
sys.exit(app.exec_())