Python PyQt5.QtWidgets.QMessageBox 模块,Warning() 实例源码

我们从Python开源项目中,提取了以下10个代码示例,用于说明如何使用PyQt5.QtWidgets.QMessageBox.Warning()

项目:ovirt-desktop-client    作者:nkovacne    | 项目源码 | 文件源码
def logout_warn(self):
        """
            Description: Called if the warn_autologout setting has been set in the config. It
                         will warn user to reset their idle, otherwise an enforced logout will
                         be performed by calling the logout() method.
            Arguments: None
            Returns: Nothing
        """

        self.autologoutwarnwin = QMessageBox(None)
        self.autologoutwarnwin.setIcon(QMessageBox.Warning)

        self.autologoutwarnwin.setText(_('auto_logout_warn'))
        self.autologoutwarnwin.setWindowTitle(_('auto_logout_warn_title'))
        self.autologoutwarnwin.setStandardButtons(QMessageBox.Ok)
        self.autologoutwarnwin.buttonClicked.connect(self.autologoutwarn_accepted)
        self.autologoutwarnwin.exec_()
项目:BigBrotherBot-For-UrT43    作者:ptitbigorneau    | 项目源码 | 文件源码
def process_start(self, row, process, warn=True):
        """
        Handle the startup of a B3 process.
        :param row: the number of the row displaying the process state
        :param process: the QProcess instance to start
        :param warn: whether to warn the user of a startup failure or not
        """
        if process.state() != QProcess.Running:
            # refresh the config before running
            process.config = process.config_path
            self.paint_row(row)
            if process.isFlag(CONFIG_READY):
                process.stateChanged.connect(partial(self.paint_row, row=row))
                process.start()
            else:
                if warn:
                    suffix = 'not found' if process.isFlag(CONFIG_FOUND) else 'not valid'
                    reason = 'configuration file %s: %s' % (suffix, process.config_path)
                    msgbox = QMessageBox()
                    msgbox.setIcon(QMessageBox.Warning)
                    msgbox.setWindowTitle('WARNING')
                    msgbox.setText('%s startup failure: %s' % (process.name, reason))
                    msgbox.setStandardButtons(QMessageBox.Ok)
                    msgbox.exec_()
项目:MDT    作者:cbclab    | 项目源码 | 文件源码
def __init__(self, problems, *args):
        super(ProtocolWarningBox, self).__init__(*args)
        self.setIcon(QMessageBox.Warning)
        self.setWindowTitle("Insufficient protocol")
        self.setText("The provided protocol is insufficient for this model.")
        self.setInformativeText("The reported problems are: \n{}".format('\n'.join(' - ' + str(p) for p in problems)))
        self._in_resize = False
项目:BigBrotherBot-For-UrT43    作者:ptitbigorneau    | 项目源码 | 文件源码
def process_console(self, process):
        """
        Display the STDOut console of a process.
        """
        if not process.stdout:
            msgbox = QMessageBox()
            msgbox.setIcon(QMessageBox.Warning)
            msgbox.setWindowTitle('WARNING')
            msgbox.setText('%s console initialization failed!' % process.name)
            msgbox.setStandardButtons(QMessageBox.Ok)
            msgbox.exec_()
        else:
            process.stdout.show()
项目:BigBrotherBot-For-UrT43    作者:ptitbigorneau    | 项目源码 | 文件源码
def process_config(self, process):
        """
        Open the B3 instance configuration file.
        """
        if not process.isFlag(CONFIG_FOUND):
            msgbox = QMessageBox()
            msgbox.setIcon(QMessageBox.Warning)
            msgbox.setWindowTitle('WARNING')
            msgbox.setText('Missing %s configuration file' % process.name)
            msgbox.setStandardButtons(QMessageBox.Ok)
            msgbox.exec_()
        else:
            B3App.Instance().openpath(process.config.fileName)
项目:BigBrotherBot-For-UrT43    作者:ptitbigorneau    | 项目源码 | 文件源码
def process_log(self, process):
        """
        Open the B3 instance log file.
        """
        try:

            if not process.isFlag(CONFIG_FOUND):
                raise ConfigFileNotFound('missing configuration file (%s)' % process.config_path)
            elif not process.isFlag(CONFIG_VALID):
                raise ConfigFileNotValid('invalid configuration file (%s)' % process.config_path)

            if not process.config.has_option('b3', 'logfile'):
                raise Exception('missing b3::logfile option in %s configuration file' % process.name)

            path = b3.getAbsolutePath(process.config.get('b3', 'logfile'), decode=True, conf=process.config)
            if not os.path.isfile(path):
                message = '- missing: %s' % path
                path = os.path.join(b3.HOMEDIR, os.path.basename(path))
                if not os.path.isfile(path):
                    raise Exception(message + '\n- missing: %s' % path)

        except Exception, err:
            msgbox = QMessageBox()
            msgbox.setIcon(QMessageBox.Warning)
            msgbox.setWindowTitle('WARNING')
            msgbox.setText('%s log file no found' % process.name)
            msgbox.setDetailedText(err.message)
            msgbox.setStandardButtons(QMessageBox.Ok)
            msgbox.layout().addItem(QSpacerItem(400, 0, QSizePolicy.Minimum, QSizePolicy.Expanding),
                                    msgbox.layout().rowCount(), 0, 1, msgbox.layout().columnCount())
            msgbox.exec_()
        else:
            B3App.Instance().openpath(path)
项目:BigBrotherBot-For-UrT43    作者:ptitbigorneau    | 项目源码 | 文件源码
def open_extplugins_directory(self):
        """
        Open the default extplugins directory.
        """
        self.make_visible()
        extplugins_dir = b3.getAbsolutePath('@b3/extplugins', True)
        if not os.path.isdir(extplugins_dir):

            try:
                LOG.warning('missing %s directory: attempt to create it' % extplugins_dir)
                os.mkdir(extplugins_dir)
                with open(os.path.join(extplugins_dir, '__init.__py'), 'w') as f:
                    f.write('#')
            except Exception, err:
                LOG.error('could create default extplugins directory: %s', err)
                msgbox = QMessageBox()
                msgbox.setIcon(QMessageBox.Warning)
                msgbox.setWindowTitle('WARNING')
                msgbox.setText('Missing 3rd party plugins directory!')
                msgbox.setDetailedText('B3 could not create missing 3rd party plugins directory (%s). '
                                       'Please make sure B3 has writing permissions on "%s"' % (extplugins_dir,
                                                                                                b3.getAbsolutePath('@b3//', True)))
                msgbox.setStandardButtons(QMessageBox.Ok)
                msgbox.exec_()
                return
            else:
                LOG.debug('created directory %s: resuming directory prompt' % extplugins_dir)

        B3App.Instance().openpath(extplugins_dir)
项目:persepolis    作者:persepolisdm    | 项目源码 | 文件源码
def deleteFile(self, menu):
        # show Warning message to the user.
        # check persepolis_setting first!
        # perhaps user checked "do not show this message again"
        delete_warning_message = self.persepolis_setting.value(
            'MainWindow/delete-warning', 'yes')

        if delete_warning_message == 'yes':
            self.msgBox = QMessageBox()
            self.msgBox.setText("<b><center>This operation will delete \
                    downloaded files from your hard disk<br>PERMANENTLY!</center></b>")
            self.msgBox.setInformativeText("<center>Do you want to continue?</center>")
            self.msgBox.setStandardButtons(QMessageBox.Yes | QMessageBox.No)
            self.msgBox.setIcon(QMessageBox.Warning)
            dont_show_checkBox = QtWidgets.QCheckBox("don't show this message again")
            self.msgBox.setCheckBox(dont_show_checkBox)
            reply = self.msgBox.exec_()

            # if user checks "do not show this message again!", change persepolis_setting!
            if self.msgBox.checkBox().isChecked():
                self.persepolis_setting.setValue(
                        'MainWindow/delete-warning', 'no')

            # do nothing if user clicks NO
            if reply != QMessageBox.Yes:
                return

        # if checking_flag is equal to 1, it means that user pressed remove or
        # delete button or ... . so checking download information must be
        # stopped until job is done!
        if checking_flag != 2:
            wait_check = WaitThread()
            self.threadPool.append(wait_check)
            self.threadPool[len(self.threadPool) - 1].start()
            self.threadPool[len(self.threadPool) -
                            1].QTABLEREADY.connect(self.deleteFile2)
        else:
            self.deleteFile2()
项目:persepolis    作者:persepolisdm    | 项目源码 | 文件源码
def deleteSelected(self, menu):
        # showing Warning message to the user.
        # checking persepolis_setting first!
        # perhaps user was checking "do not show this message again"
        delete_warning_message = self.persepolis_setting.value(
            'MainWindow/delete-warning', 'yes')

        if delete_warning_message == 'yes':
            self.msgBox = QMessageBox()
            self.msgBox.setText("<b><center>This operation will delete \
                    downloaded files from your hard disk<br>PERMANENTLY!</center></b>")
            self.msgBox.setInformativeText("<center>Do you want to continue?</center>")
            self.msgBox.setStandardButtons(QMessageBox.Yes | QMessageBox.No)
            self.msgBox.setIcon(QMessageBox.Warning)
            dont_show_checkBox = QtWidgets.QCheckBox("don't show this message again")
            self.msgBox.setCheckBox(dont_show_checkBox)
            reply = self.msgBox.exec_()

            # if user checks "do not show this message again!", change persepolis_setting!
            if self.msgBox.checkBox().isChecked():
                self.persepolis_setting.setValue(
                        'MainWindow/delete-warning', 'no')

            # do nothing if user clicks NO
            if reply != QMessageBox.Yes:
                return


        # if checking_flag is equal to 1, it means that user pressed remove or
        # delete button or ... . so checking download information must be
        # stopped until job is done!
        if checking_flag != 2:
            wait_check = WaitThread()
            self.threadPool.append(wait_check)
            self.threadPool[len(self.threadPool) - 1].start()
            self.threadPool[len(self.threadPool) -
                            1].QTABLEREADY.connect(self.deleteSelected2)
        else:
            self.deleteSelected2()
项目:persepolis    作者:persepolisdm    | 项目源码 | 文件源码
def removeQueue(self, menu):
        # show Warning message to user.
        # checks persepolis_setting first!
        # perhaps user was checking "do not show this message again"
        remove_warning_message = self.persepolis_setting.value(
            'MainWindow/remove-queue-warning', 'yes')

        if remove_warning_message == 'yes':
            self.remove_queue_msgBox = QMessageBox()
            self.remove_queue_msgBox.setText('<b><center>This operation will remove \
                    all download items in this queue<br>from "All Downloads" list!</center></b>')

            self.remove_queue_msgBox.setInformativeText("<center>Do you want to continue?</center>")
            self.remove_queue_msgBox.setStandardButtons(QMessageBox.Yes | QMessageBox.No)
            self.remove_queue_msgBox.setIcon(QMessageBox.Warning)
            dont_show_checkBox = QtWidgets.QCheckBox("don't show this message again")
            self.remove_queue_msgBox.setCheckBox(dont_show_checkBox)
            reply = self.remove_queue_msgBox.exec_()

            # if user checks "do not show this message again!", change persepolis_setting!
            if self.remove_queue_msgBox.checkBox().isChecked():
                self.persepolis_setting.setValue(
                        'MainWindow/remove-queue-warning', 'no')

            # do nothing if user clicks NO
            if reply != QMessageBox.Yes:
                return


        # find name of queue
        current_category_tree_text = str(current_category_tree_index.data())

        if current_category_tree_text == 'Scheduled Downloads':
            error_messageBox = QMessageBox()
            error_messageBox.setText(
                    "<b>Sorry! You can't remove default queue!</b>")
            error_messageBox.setWindowTitle('Error!')
            error_messageBox.exec_()

            return


        if current_category_tree_text != 'All Downloads' and current_category_tree_text != 'Single Downloads':

            # remove queue from category_tree
            row_number = current_category_tree_index.row()
            self.category_tree_model.removeRow(row_number)

            # delete category from data base
            self.persepolis_db.deleteCategory(current_category_tree_text)


        # highlight "All Downloads" in category_tree
        all_download_index = self.category_tree_model.index(0, 0)
        self.category_tree.setCurrentIndex(all_download_index)
        self.categoryTreeSelected(all_download_index)


    # this method starts the queue that is selected in category_tree