1 Star 0 Fork 4

Anzong/LibraryManageDesktopApp

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
MainWindow.py 4.20 KB
一键复制 编辑 原始数据 按行查看 历史
俞晨东 提交于 2018-04-28 14:23 . all done
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_())
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/anzong/LibraryManageDesktopApp.git
git@gitee.com:anzong/LibraryManageDesktopApp.git
anzong
LibraryManageDesktopApp
LibraryManageDesktopApp
master

搜索帮助