本文整理汇总了Python中core.Core.logOut方法的典型用法代码示例。如果您正苦于以下问题:Python Core.logOut方法的具体用法?Python Core.logOut怎么用?Python Core.logOut使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类core.Core
的用法示例。
在下文中一共展示了Core.logOut方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: PyAuth
# 需要导入模块: from core import Core [as 别名]
# 或者: from core.Core import logOut [as 别名]
class PyAuth(QMainWindow):
"""Main window class."""
def __init__(self):
super(PyAuth, self).__init__()
self.setGeometry(500, 300, 200, 100)
self.setFixedSize(500, 300)
self.__setupMenu()
self.app = Core()
self.requestCredentials()
def __setupMenu(self):
"""Defines basic top menu"""
quit_action = QAction("&Exit", self)
quit_action.setShortcut('Ctrl+Q')
quit_action.triggered.connect(self.close)
sign_out_action = QAction("Sign out", self)
sign_out_action.setShortcut('Ctrl+L')
sign_out_action.triggered.connect(lambda: (self.app.logOut(), self.hide(), self.requestCredentials()))
change_password_action = QAction("Change password", self)
change_password_action.triggered.connect(self.requestPasswordChange)
about_action = QAction("About", self)
about_action.triggered.connect(lambda: QMessageBox.about(self, "About", u'© ' + __author__ + ' 2013'))
self.file_menu = self.menuBar().addMenu("&File")
self.file_menu.addAction(quit_action)
self.account_menu = self.menuBar().addMenu("&Account")
self.account_menu.addAction(sign_out_action)
self.account_menu.addAction(change_password_action)
self.help_menu = self.menuBar().addMenu("&Help")
self.help_menu.addAction(about_action)
def requestPasswordChange(self):
"""Requests dialog for password change."""
dialog = None
def ok_handler(oldPassword, password, confirm):
if 5 > len(password) > 30:
QMessageBox.critical(dialog, "Error", "Password must be between 6 and 30 char length")
return
if password != confirm:
QMessageBox.critical(dialog, "Error", "Passwords don't match")
return
status = self.app.changePassword(oldPassword, password)
{
Core.ERROR_OLD_PASSWORD: lambda:
QMessageBox.critical(dialog, "Error", "Wrong old password.", modal=True),
Core.ERROR_PASSWORD_RESTRICTION: lambda:
QMessageBox.critical(dialog, "Error", "Password is too weak.", modal=True),
Core.SUCCESS: lambda: dialog.close()
}[status]()
def cancel_handler():
dialog.close()
dialog = ChangePasswordDialog(self, ok_handler, cancel_handler)
dialog.show()
def requestCredentials(self):
"""Requests form for credentials input"""
dialog = None
def ok_handler(username, password):
status = self.app.logIn(username, password)
{
Core.ERROR_INCORRECT_CREDENTIALS: lambda:
QMessageBox.critical(dialog, "Error", "Incorrect username or password", modal=True),
Core.ERROR_USER_IS_BLOCKED: lambda:
QMessageBox.critical(dialog, "Error", "Your account is blocked", modal=True),
Core.ERROR_ATTEMPTS: self.close,
Core.SUCCESS: lambda: (
self.showAdminWidget() if self.app.currentUser.admin else self.showCustomerWidget(),
dialog.close()
)
}[status]()
def cancel_handler():
sys.exit()
dialog = SignInDialog(self, ok_handler, cancel_handler)
dialog.show()
def showAdminWidget(self):
"""Requests admin panel."""
self.setCentralWidget(AdminWidget(self))
self.show()
def showCustomerWidget(self):
"""Requests customers panel."""
self.setCentralWidget(CustomerWidget(self))
self.show()