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


Python QUiLoader.setWindowModality方法代码示例

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


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

示例1: Update_Window

# 需要导入模块: from PySide.QtUiTools import QUiLoader [as 别名]
# 或者: from PySide.QtUiTools.QUiLoader import setWindowModality [as 别名]
class Update_Window(QDialog):

    # def __init__(self, parent=None):
    #     QDialog.__init__(self, parent)
    def __init__(self, parent=None):
        super(Update_Window, self).__init__(parent)

        self.getPath_update = os.path.abspath(os.path.join('gui', 'pp_update.ui'))

        try:
            self.ui_pp_update = QUiLoader()
            self.file = QFile(self.getPath_search_ui, self)
            self.file.open(QFile.ReadOnly)
            self.myWidget = self.ui_pp_update.load(file, self)
            self.file.close()
            print "STATUS [OK]  ", FILE_NAME, ": GUI is loaded from PySide"
        except:
            self.ui_pp_update = loadUi(self.getPath_update, self)
            print "STATUS [OK]  ", FILE_NAME, ": GUI is loaded from PyQt4"

        self.ui_pp_update.setWindowModality(Qt.ApplicationModal)


        # Set data for download and saving in path
        self.location = os.path.abspath(os.path.join('temp', 'example-app-0.3.win32.zip'))
        self.url = 'http://sophus.bplaced.net/download/example-app-0.3.win32.zip'

        self.download_task = Download_Thread(self.location, self.url)
        self.download_task.notify_progress.connect(self.on_progress)
        self.download_task.finished_thread.connect(self.on_finished)
        self.download_task.error_http.connect(self.on_HTTPError)
        self.download_task.finished_download.connect(self.on_finish_download)

        self.ui_pp_update.pushButtonUpdate.setEnabled(True)
        self.create_actions_buttons()

    def on_start(self):
        self.ui_pp_update.progressBarUpdate.setRange(0, 0)
        self.download_task.start()

    def on_finish_download(self):
        msg_box = QMessageBox()
        QMessageBox.question(msg_box, ' Message ',
                                           "The file has been fully downloaded.", msg_box.Ok)

    def on_HTTPError(self):
        reply = QMessageBox.question(self, ' Error ',
                                           "The file could not be downloaded. Will they do it again?", QMessageBox.Yes |
            QMessageBox.No, QMessageBox.No)

        if reply == QMessageBox.Yes:
            self.on_start()
        else:
            event.ignore()

    def on_progress(self, i):
        self.ui_pp_update.progressBarUpdate.setRange(0, 100)
        self.ui_pp_update.progressBarUpdate.setValue(i)

    def stop_progress(self):
        self.download_task.stop()
        self.ui_pp_update.progressBarUpdate.setValue(0)

    def check_folder_exists(self):
        location = os.path.abspath(os.path.join('temp'))
        if not os.path.exists(location):
            os.makedirs(location)
            print "Folder was created"
            self.on_start()
        else:
            print "Folder already exists"
            self.on_start()

    def on_finished(self):
        self.download_task.stop()
        self.ui_pp_update.progressBarUpdate.setValue(0)
        self.close()

    def set_ui_pp_update(self):
        self.ui_pp_update.progressBarUpdate.setAlignment(Qt.AlignCenter)
        self.ui_pp_update.progressBarUpdate.setValue(0)

    def create_actions_buttons(self):
        self.ui_pp_update.pushButtonUpdate.clicked.connect(self.check_folder_exists)
        self.ui_pp_update.pushButtonCancel.clicked.connect(self.stop_progress)
        self.ui_pp_update.pushButtonClose.clicked.connect(self.on_finished)

    def closeEvent(self, event):
        self.download_task.stop()

    def show_and_raise(self):
        self.show()
        self.raise_()
开发者ID:Xarphus,项目名称:Xarphus,代码行数:95,代码来源:update.py


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