当前位置: 首页>>代码示例>>Python>>正文


Python MainWindow.showProgress方法代码示例

本文整理汇总了Python中main_window.MainWindow.showProgress方法的典型用法代码示例。如果您正苦于以下问题:Python MainWindow.showProgress方法的具体用法?Python MainWindow.showProgress怎么用?Python MainWindow.showProgress使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在main_window.MainWindow的用法示例。


在下文中一共展示了MainWindow.showProgress方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: PSSOptimisation

# 需要导入模块: from main_window import MainWindow [as 别名]
# 或者: from main_window.MainWindow import showProgress [as 别名]

#.........这里部分代码省略.........

        # and put it into the main window's menus
        self.main_window.menu_table_columns.clear()
        for action in self.header_actions.actions():
            self.main_window.menu_table_columns.addAction(action)

        # automatically download new grades (depends on settings)
        if self.settings.value("updateOnStart", False).toBool():
            QtCore.QTimer.singleShot(200, self.tryAutoDownloadFromPSSO)
    
    def openLoginDialog(self):
        self.login_dialog = LoginDialog(self.main_window)
        self.login_dialog.exec_()
        if self.login_dialog.result():
            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 "")
开发者ID:amrni,项目名称:PSSOptimisation2,代码行数:70,代码来源:main.py


注:本文中的main_window.MainWindow.showProgress方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。