forked from syx9527/LibraryManage
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStudentHome.py
133 lines (114 loc) · 5.26 KB
/
StudentHome.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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'StudentHome.ui'
#
# Created by: PyQt5 UI code generator 5.12.1
#
# WARNING! All changes made in this file will be lost!
from PyQt5 import QtCore, QtGui, QtWidgets
import sys
from PyQt5.QtWidgets import *
from PyQt5.QtGui import QIcon, QFont
import sip
import qdarkstyle
from BookStorageViewer import BookStorageViewer
from borrowBookDialog import borrowBookDialog
from returnBookDialog import returnBookDialog
from BorrowStatusViewer import BorrowStatusViewer
class StudentHome(QWidget):
def __init__(self, studentId):
super().__init__()
self.StudentId = studentId
self.setupUi()
def setupUi(self ):
# self.setObjectName("self")
self.resize(1200, 600)
self.layout = QtWidgets.QHBoxLayout(self)
self.layout.setObjectName("layout")
self.buttonLayout = QtWidgets.QVBoxLayout()
self.buttonLayout.setObjectName("buttonLayout")
self.borrowBookButton = QtWidgets.QPushButton(self)
self.borrowBookButton.setEnabled(True)
self.borrowBookButton.setMaximumSize(QtCore.QSize(100, 42))
font = QtGui.QFont()
font.setPointSize(16)
self.borrowBookButton.setFont(font)
self.borrowBookButton.setObjectName("borrowBookButton")
self.buttonLayout.addWidget(self.borrowBookButton)
self.returnBookButton = QtWidgets.QPushButton(self)
self.returnBookButton.setMaximumSize(QtCore.QSize(100, 42))
font = QtGui.QFont()
font.setPointSize(16)
self.returnBookButton.setFont(font)
self.returnBookButton.setObjectName("returnBookButton")
self.buttonLayout.addWidget(self.returnBookButton)
self.myBookStatus = QtWidgets.QPushButton(self)
self.myBookStatus.setMaximumSize(QtCore.QSize(100, 42))
font = QtGui.QFont()
font.setPointSize(16)
self.myBookStatus.setFont(font)
self.myBookStatus.setObjectName("myBookStatus")
self.buttonLayout.addWidget(self.myBookStatus)
self.allBookButton = QtWidgets.QPushButton(self)
self.allBookButton.setMaximumSize(QtCore.QSize(100, 42))
font = QtGui.QFont()
font.setPointSize(16)
self.allBookButton.setFont(font)
self.allBookButton.setObjectName("allBookButton")
self.buttonLayout.addWidget(self.allBookButton)
self.storageView = BookStorageViewer()
self.borrowStatusView = BorrowStatusViewer(self.StudentId)
self.allBookButton.setEnabled(False)
self.layout.addLayout(self.buttonLayout)
self.layout.addWidget(self.storageView)
self.retranslateUi()
QtCore.QMetaObject.connectSlotsByName(self)
self.borrowBookButton.clicked.connect(self.borrowBookButtonClicked)
self.returnBookButton.clicked.connect(self.returnBookButtonClicked)
self.myBookStatus.clicked.connect(self.myBookStatusClicked)
self.allBookButton.clicked.connect(self.allBookButtonClicked)
def retranslateUi(self, ):
_translate = QtCore.QCoreApplication.translate
self.setWindowTitle(_translate("StudentHome", "欢迎使用图书馆管理系统"))
self.borrowBookButton.setText(_translate("StudentHome", "借书"))
self.returnBookButton.setText(_translate("StudentHome", "还书"))
self.myBookStatus.setText(_translate("StudentHome", "借阅状态"))
self.allBookButton.setText(_translate("StudentHome", "所有书籍"))
def borrowBookButtonClicked(self):
borrowDialog = borrowBookDialog(self.StudentId, self)
borrowDialog.borrow_book_success_signal.connect(self.borrowStatusView.borrowedQuery)
borrowDialog.borrow_book_success_signal.connect(self.storageView.searchButtonClicked)
borrowDialog.show()
borrowDialog.exec_()
return
def returnBookButtonClicked(self):
returnDialog = returnBookDialog(self.StudentId, self)
returnDialog.return_book_success_signal.connect(self.borrowStatusView.returnedQuery)
returnDialog.return_book_success_signal.connect(self.borrowStatusView.borrowedQuery)
returnDialog.return_book_success_signal.connect(self.storageView.searchButtonClicked)
returnDialog.show()
returnDialog.exec_()
def myBookStatusClicked(self):
self.layout.removeWidget(self.storageView)
sip.delete(self.storageView)
self.storageView = BookStorageViewer()
self.borrowStatusView = BorrowStatusViewer(self.StudentId)
self.layout.addWidget(self.borrowStatusView)
self.allBookButton.setEnabled(True)
self.myBookStatus.setEnabled(False)
return
def allBookButtonClicked(self):
self.layout.removeWidget(self.borrowStatusView)
sip.delete(self.borrowStatusView)
self.borrowStatusView = BorrowStatusViewer(self.StudentId)
self.storageView = BookStorageViewer()
self.layout.addWidget(self.storageView)
self.allBookButton.setEnabled(False)
self.myBookStatus.setEnabled(True)
return
if __name__ == "__main__":
app = QApplication(sys.argv)
app.setWindowIcon(QIcon("./images/MainWindow_1.ico"))
# app.setStyleSheet(qdarkstyle.load_stylesheet_pyqt5())
mainMindow = StudentHome("PB15000135")
mainMindow.show()
sys.exit(app.exec_())