def __init__(self, parent=None): super(Main, self).__init__(parent) self.layout = QHBoxLayout() self.widget = SignInWidget() self.resize(self.iFenbianlv_x, self.iFenbianlv_y) self.setWindowTitle("银河智维AI平台") self.setCentralWidget(self.widget) bar = self.menuBar() self.Menu = bar.addMenu("菜单栏") self.signUpAction = QAction("模型演示", self) self.inTrainAction = 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.inTrainAction) self.Menu.addAction(self.changePasswordAction) # self.Menu.addAction(self.signInAction) # self.Menu.addAction(self.quitSignInAction) self.Menu.addAction(self.quitAction) self.signUpAction.setEnabled(False) self.inTrainAction.setEnabled(False) 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 __init__(self): super().__init__() bar = self.menuBar() self.Menu = bar.addMenu("菜单栏") self.signInAction = QAction("登录", self) self.quitSignInAction = QAction("退出登录", self) self.quitAction = QAction("退出", self) self.Menu.addAction(self.signInAction) self.Menu.addAction(self.quitSignInAction) self.Menu.addAction(self.quitAction) self.Menu.triggered[QAction].connect(self.menuTriggered) self.signInAction.setEnabled(False) self.quitSignInAction.setEnabled(False) isLogin = gfunc.isLoginForLocal() if isLogin: self.widget = Home() self.setCentralWidget(self.widget) self.signInAction.setEnabled(False) self.quitSignInAction.setEnabled(True) else: self.widget = SignInWidget() self.setCentralWidget(self.widget) self.widget.login_signal[str, str].connect(self.loginSuccess)
def __init__(self, parent=None): super(Main, self).__init__(parent) self.layout = QHBoxLayout() self.widget = SignInWidget() self.resize(900, 600) self.setWindowTitle("OneSearch信息管理系统") self.setCentralWidget(self.widget) bar = self.menuBar() self.Menu = bar.addMenu("菜单栏") # 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) #quit按钮是默认激活的 # self.quitAction.setEnabled(False) #不用管这个Quit #绑定方法,跳跃至其他界面的操作 self.widget.is_admin_signal.connect(self.adminSignIn) #如果是user,则是connect这个方法 self.widget.is_user_signal[str].connect(self.userSignIn) self.Menu.triggered[QAction].connect(self.menuTriggered)
def __init__(self, parent=None): super(Main, self).__init__(parent) self.initDBdata() 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 studentSignIn(self, studentId): delete(self.widget) self.widget = AdminHome() self.setCentralWidget(self.widget) self.signUpAction.setEnabled(False) self.inTrainAction.setEnabled(True) self.changePasswordAction.setEnabled(False)
def menuTriggered(self, q): if(q.text()=="修改密码"): changePsdDialog=changePasswordDialog(self) changePsdDialog.show() changePsdDialog.exec_() if (q.text() == "注册"): sip.delete(self.widget) print("clicked reg") self.widget = SignUpWidget() self.setCentralWidget(self.widget) self.widget.user_signup_signal[str].connect(self.userSignIn) self.signUpAction.setEnabled(False) self.changePasswordAction.setEnabled(True) self.signInAction.setEnabled(True) self.quitSignInAction.setEnabled(False) print("_"*50) #这里仅仅是退出登录而已,还是需要保留界面,以待其余用户登录使用或注册 if (q.text() == "退出登录"): sip.delete(self.widget) #粗暴删除原有界面widget,随后重新实例SignWidgets self.widget = SignInWidget() self.setCentralWidget(self.widget) #捆绑方法 self.widget.is_admin_signal.connect(self.adminSignIn) self.widget.is_user_signal[str].connect(self.userSignIn) 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_user_signal[str].connect(self.userSignIn) self.signUpAction.setEnabled(True) self.changePasswordAction.setEnabled(True) self.signInAction.setEnabled(False) self.quitSignInAction.setEnabled(False) if (q.text() == "退出"): #产生实例后调用quit方法 qApp = QApplication.instance() qApp.quit() return
def menuTriggered(self, q): if (q.text() == "退出登录"): sip.delete(self.widget) self.widget = SignInWidget() self.setCentralWidget(self.widget) self.widget.login_signal[str, str].connect(self.loginSuccess) self.signInAction.setEnabled(False) self.quitSignInAction.setEnabled(False) gfunc.setLoginForLocal(False) if (q.text() == "登录"): sip.delete(self.widget) self.widget = SignInWidget() self.setCentralWidget(self.widget) self.widget.login_signal[str, str].connect(self.loginSuccess) self.signInAction.setEnabled(False) self.quitSignInAction.setEnabled(False) if (q.text() == "退出"): qApp = QApplication.instance() qApp.quit()
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.adminSignIn) self.signUpAction.setEnabled(False) self.changePasswordAction.setEnabled(True) self.signInAction.setEnabled(True) self.logoutAdminAction.setEnabled(False) if (q.text() == "添加用户"): # sip.delete(self.widget) # self.widget = SignUpUserWidget() # self.setCentralWidget(self.widget) # self.widget.student_signupuser_signal[str].connect(self.adminSignIn) # self.signUpUserAction.setEnabled(False) SingUpUserDialog = SignUpUserWidget(self) SingUpUserDialog.show() SingUpUserDialog.exec_() if (q.text() == "注销管理员"): # sip.delete(self.widget) # self.widget = logoutAdminWidget() # self.setCentralWidget(self.widget) # self.widget.student_logoutAdmin_signal[str].connect(self.adminSignIn) # self.signUpAction.setEnabled(True) # self.changePasswordAction.setEnabled(True) # self.signInAction.setEnabled(False) # self.logoutAdminAction.setEnabled(False) # qApp = QApplication.instance() # qApp.quit() logoutAdminDialog = logoutAdminWidget(self) logoutAdminDialog.show() logoutAdminDialog.exec_() 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.logoutAdminAction.setEnabled(False) if (q.text() == "退出"): qApp = QApplication.instance() qApp.quit() return
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
def menuTriggered(self,q): if(q.text() == "注 册"): self.widget = SignUpWidget() self.setCentralWidget(self.widget) self.signupaction.setEnabled(False) self.changepswaction.setEnabled(True) self.signinaction.setEnabled(True) self.quitsigninaction.setEnabled(False) if(q.text() == "登 录"): self.widget = SignInWidget() self.setCentralWidget(self.widget) self.widget.is_admin_signal[str].connect(self.adminSignIn) self.widget.is_user_signal[str].connect(self.userSignIn) self.signupaction.setEnabled(True) self.changepswaction.setEnabled(True) self.signinaction.setEnabled(False) self.quitsigninaction.setEnabled(False) if(q.text() == "退出登录"): self.widget = SignInWidget() self.setCentralWidget(self.widget) self.widget.is_admin_signal[str].connect(self.adminSignIn) self.widget.is_user_signal[str].connect(self.userSignIn) self.signupaction.setEnabled(True) self.changepswaction.setEnabled(True) self.signinaction.setEnabled(False) self.quitsigninaction.setEnabled(False) if (q.text() == "修改密码"): changepswDialog = ChangePswDialog() changepswDialog.show() changepswDialog.exec_() if(q.text() == "关 于"): aboutDialog = AboutDialog() aboutDialog.show() aboutDialog.exec_() if(q.text() == "退 出"): qApp = QApplication.instance() qApp.quit() return
def initUI(self): self.resize(800, 600) self.setWindowTitle('myPet——欢迎使用宠物招领系统') self.setWindowIcon(QIcon('./images/icon.png')) self.widget = SignInWidget() self.setCentralWidget(self.widget) menubar = self.menuBar() menubar.setFont(QFont("苏新诗柳楷繁", 15)) self.menu = menubar.addMenu('菜单栏') self.menu.setFont(QFont("苏新诗柳楷繁", 15)) self.signupaction = QAction("注 册",self) self.signupaction.setShortcut('Ctrl+U') self.signinaction = QAction('登 录',self) self.signinaction.setShortcut('Ctrl+I') self.changepswaction = QAction("修改密码", self) self.changepswaction.setShortcut('Ctrl+C') self.aboutaction = QAction("关 于",self) self.aboutaction.setShortcut('Ctrl+A') self.quitsigninaction = QAction("退出登录",self) self.quitsigninaction.setShortcut('Ctrl+T') self.quitaction = QAction("退 出", self) self.quitaction.setShortcut('Ctrl+Q') self.menu.addAction(self.signupaction) self.menu.addAction(self.signinaction) self.menu.addAction(self.changepswaction) self.menu.addAction(self.aboutaction) self.menu.addAction(self.quitsigninaction) self.menu.addAction(self.quitaction) self.signupaction.setEnabled(True) self.changepswaction.setEnabled(True) self.signinaction.setEnabled(False) self.quitsigninaction.setEnabled(False) self.widget.is_admin_signal[str].connect(self.adminSignIn) self.widget.is_user_signal[str].connect(self.userSignIn) self.menu.triggered[QAction].connect(self.menuTriggered)
def menuTriggered(self, q): if (q.text() == "修改密码"): changePsdDialog = changePasswordDialog(self) changePsdDialog.show() changePsdDialog.exec_() if (q.text() == "模型演示"): self.yanshi_flag = 2 delete(self.widget) self.widget = AdminHome() self.setCentralWidget(self.widget) self.signUpAction.setEnabled(False) self.inTrainAction.setEnabled(True) self.changePasswordAction.setEnabled(True) # self.signInAction.setEnabled(True) # self.quitSignInAction.setEnabled(True) if (q.text() == "模型训练"): if self.yanshi_flag == 2 or self.yanshi_flag == 0: if self.widget.flag != 0: self.yanshi_flag = 1 self.widget.close() delete(self.widget) self.widget = inTrainWidget() self.setCentralWidget(self.widget) self.signUpAction.setEnabled(True) self.inTrainAction.setEnabled(False) self.changePasswordAction.setEnabled(True) # self.signInAction.setEnabled(False) # self.quitSignInAction.setEnabled(True) if (q.text() == "退出登录"): if self.yanshi_flag == 2 or self.yanshi_flag == 0: if self.widget.flag != 0: self.yanshi_flag == 0 self.widget.close() if self.yanshi_flag == 1: self.widget.stopThreading() self.yanshi_flag == 0 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(True) # self.quitSignInAction.setEnabled(False) if (q.text() == "登录"): 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(True) # self.quitSignInAction.setEnabled(True) if (q.text() == "退出"): if self.yanshi_flag == 2 or self.yanshi_flag == 0: if self.widget.flag != 0: self.yanshi_flag == 0 self.widget.close() if self.yanshi_flag == 1: self.widget.stopThreading() self.yanshi_flag == 0 qApp = QApplication.instance() qApp.quit() return
class Main(QMainWindow): iFenbianlv_x = GetSystemMetrics(SM_CXSCREEN) iFenbianlv_y = GetSystemMetrics(SM_CYSCREEN) yanshi_flag = 0 def __init__(self, parent=None): super(Main, self).__init__(parent) self.layout = QHBoxLayout() self.widget = SignInWidget() self.resize(self.iFenbianlv_x, self.iFenbianlv_y) self.setWindowTitle("银河智维AI平台") self.setCentralWidget(self.widget) bar = self.menuBar() self.Menu = bar.addMenu("菜单栏") self.signUpAction = QAction("模型演示", self) self.inTrainAction = 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.inTrainAction) self.Menu.addAction(self.changePasswordAction) # self.Menu.addAction(self.signInAction) # self.Menu.addAction(self.quitSignInAction) self.Menu.addAction(self.quitAction) self.signUpAction.setEnabled(False) self.inTrainAction.setEnabled(False) 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): delete(self.widget) self.widget = AdminHome() self.setCentralWidget(self.widget) self.signUpAction.setEnabled(False) self.inTrainAction.setEnabled(True) self.changePasswordAction.setEnabled(True) # self.signInAction.setEnabled(True) # self.quitSignInAction.setEnabled(True) def studentSignIn(self, studentId): delete(self.widget) self.widget = AdminHome() self.setCentralWidget(self.widget) self.signUpAction.setEnabled(False) self.inTrainAction.setEnabled(True) self.changePasswordAction.setEnabled(False) # self.signInAction.setEnabled(False) # self.quitSignInAction.setEnabled(True) def inTrainModel(self): delete(self.widget) self.widget = inTrainWidget() self.setCentralWidget(self.widget) self.changePasswordAction.setEnabled(True) 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() == "模型演示"): self.yanshi_flag = 2 delete(self.widget) self.widget = AdminHome() self.setCentralWidget(self.widget) self.signUpAction.setEnabled(False) self.inTrainAction.setEnabled(True) self.changePasswordAction.setEnabled(True) # self.signInAction.setEnabled(True) # self.quitSignInAction.setEnabled(True) if (q.text() == "模型训练"): if self.yanshi_flag == 2 or self.yanshi_flag == 0: if self.widget.flag != 0: self.yanshi_flag = 1 self.widget.close() delete(self.widget) self.widget = inTrainWidget() self.setCentralWidget(self.widget) self.signUpAction.setEnabled(True) self.inTrainAction.setEnabled(False) self.changePasswordAction.setEnabled(True) # self.signInAction.setEnabled(False) # self.quitSignInAction.setEnabled(True) if (q.text() == "退出登录"): if self.yanshi_flag == 2 or self.yanshi_flag == 0: if self.widget.flag != 0: self.yanshi_flag == 0 self.widget.close() if self.yanshi_flag == 1: self.widget.stopThreading() self.yanshi_flag == 0 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(True) # self.quitSignInAction.setEnabled(False) if (q.text() == "登录"): 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(True) # self.quitSignInAction.setEnabled(True) if (q.text() == "退出"): if self.yanshi_flag == 2 or self.yanshi_flag == 0: if self.widget.flag != 0: self.yanshi_flag == 0 self.widget.close() if self.yanshi_flag == 1: self.widget.stopThreading() self.yanshi_flag == 0 qApp = QApplication.instance() qApp.quit() return
def SignUp2(self): UserId = self.UserIdLineEdit.text() #UserName = self.UserNameLineEdit.text() password = self.passwordLineEdit.text() confirmPassword = self.passwordConfirmLineEdit.text() if (UserId == "" or password == ""): print( QMessageBox.warning(self, "警告", "表单不可为空,请重新输入", QMessageBox.Yes, QMessageBox.Yes)) return else: # 需要处理逻辑,1.账号已存在;2.密码不匹配;3.插入user表 db = openDB() query = QSqlQuery() # md5编码 hl = hashlib.md5() hl.update(password.encode(encoding='utf-8')) md5password = hl.hexdigest() import time changeDate = time.strftime("%Y-%m-%d %H:%M:%S") changeId = 0 # 表示为自己注册 sql = "SELECT * FROM User WHERE UserId='%s'" % (UserId) query.exec_(sql) if (query.next()): print( QMessageBox.warning(self, "警告", "该账号已存在,请重新输入", QMessageBox.Yes, QMessageBox.Yes)) return else: if (not password == confirmPassword): print( QMessageBox.warning(self, "警告", "两次密码输出不一致,请重新输入", QMessageBox.Yes, QMessageBox.Yes)) return else: sql = "INSERT INTO User VALUES ('%s','%s',0,'%s','%s')" % ( UserId, md5password, changeDate, changeId) db.exec_(sql) db.commit() print( QMessageBox.information(self, "提醒", "您已成功注册账号!", QMessageBox.Yes, QMessageBox.Yes)) # Zgg #self.is_admin_signal.emit() # sip.delete(self.widget) # widget = AdminHome() # self.setCentralWidget(widget) db.close() self.close() #注册页面关闭 self.father.close() self.father.widget = SignInWidget() self.father.__init__() self.father.setCentralWidget(self.father.widget) self.father.widget.is_admin_signal.connect(self.father.adminSignIn) # self.widget.is_User_signal[str].connect(self.UserSignIn) self.father.signUpAction.setEnabled(True) self.father.ChangePasswordAction.setEnabled(True) self.father.signInAction.setEnabled(False) self.father.quitSignInAction.setEnabled(False) return