本文整理匯總了Python中main_window.MainWindow.setEnabled方法的典型用法代碼示例。如果您正苦於以下問題:Python MainWindow.setEnabled方法的具體用法?Python MainWindow.setEnabled怎麽用?Python MainWindow.setEnabled使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類main_window.MainWindow
的用法示例。
在下文中一共展示了MainWindow.setEnabled方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: PSSOptimisation
# 需要導入模塊: from main_window import MainWindow [as 別名]
# 或者: from main_window.MainWindow import setEnabled [as 別名]
#.........這裏部分代碼省略.........
username = str(self.login_dialog.username_line.text())
password = str(self.login_dialog.password_line.text())
if username and password:
remember = self.login_dialog.remember_checkbox.isChecked()
self.handleLoginData(username, password, remember)
def handleLoginData(self, username, password, remember=False):
"""Try to load the grades by using the provided login credentials.
On failure, an error popup is displayed. On success a loading progress
bar and after that a table is shown.
If "remember" is True, then the login data is saved.
"""
self.main_window.setDisabled(True)
QtGui.QApplication.processEvents()
QtGui.QApplication.processEvents()
progress = 0
try:
iterator = self.grades_model.getFromPSSOIterator(username, password)
for step in iterator:
self.main_window.showProgress(progress, step)
# getFromPSSOIterator defines 8 steps, but 1st is at 0
progress += 100.0/7
QtGui.QApplication.processEvents()
except (ConnectionError, ServiceUnavailableError, ParsingError) as e:
QtGui.QMessageBox.critical(self.main_window,
e.title, e.message)
return
except LoginError as e:
self.clearLoginData(username)
QtGui.QMessageBox.critical(self.main_window,
e.title, e.message)
return
finally:
self.main_window.setEnabled(True)
self.main_window.showProgress(-1)
self.main_window.showTable()
self.main_window.setEnabled(True)
if remember:
self.saveLoginData(username, password)
def saveLoginData(self, username, password):
assert username and password
self.settings.setValue("username", username)
keyring.set_password("PSSO", username, password)
def getLoginData(self):
"""Try to retrieve previously saved username and password. Returns
a tuple of two empty strings on failure.
"""
username = str(self.settings.value("username").toString() or "")
try:
password = keyring.get_password("PSSO", username) or ""
except IOError:
return "", ""
return username, password
def clearLoginData(self, username=None):
"""Remove username and password settings. If a username is given,
its password will be removed. If there is a saved username,
it will also get removed alongside with the corresponding password.
"""
username2 = str(self.settings.value("username").toString() or "")
try:
keyring.delete_password("PSSO", username)