__init__.py 文件源码

python
阅读 17 收藏 0 点赞 0 评论 0

项目:BigBrotherBot-For-UrT43 作者: ptitbigorneau 项目源码 文件源码
def shutdown(self):
        """
        Perform cleanup operation before the application exits.
        This is executed when the `aboutToQuit` signal is emitted, before `quit()
        or when the user shutdown the Desktop session`.
        """
        LOG.debug('shutdown requested')
        is_something_running = False
        for process in self.processes:
            if process.state() == QProcess.Running:
                is_something_running = True
                break

        if is_something_running:
            # ask the use if he wants to quit for real
            LOG.debug('some processes are still running: asking the user if he wants to terminate them...')
            msgbox = QMessageBox()
            msgbox.setIcon(QMessageBox.Question)
            msgbox.setText('Are you sure you want to quit?')
            msgbox.setInformativeText('NOTE: all the running B3 will be stopped!')
            msgbox.setStandardButtons(QMessageBox.No | QMessageBox.Yes)
            msgbox.setDefaultButton(QMessageBox.No)
            msgbox.exec_()

            if msgbox.result() == QMessageBox.Yes:
                LOG.debug('user agreed to terminate all the running processes and quit the application')
            else:
                LOG.debug('shutdown aborted')
                return

        self.shutdown_requested = True
        self.stop_all()

        ## REMOVE LOG HANDLERS
        for handler in LOG.handlers:
            handler.close()
            LOG.removeHandler(handler)

        ## HIDE SYSTEM TRAY (ON WINDOWS IT STAYS VISIBLE SOMETIME)
        if b3.getPlatform() != 'linux':
            # linux has no system tray
            self.main_window.system_tray.hide()

        ## QUIT THE APPLICATION
        self.quit()

    ############################################## OTHER METHODS #######################################################
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号