當前位置: 首頁>>代碼示例>>Python>>正文


Python QMessageBox.Critical方法代碼示例

本文整理匯總了Python中PyQt5.QtWidgets.QMessageBox.Critical方法的典型用法代碼示例。如果您正苦於以下問題:Python QMessageBox.Critical方法的具體用法?Python QMessageBox.Critical怎麽用?Python QMessageBox.Critical使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在PyQt5.QtWidgets.QMessageBox的用法示例。


在下文中一共展示了QMessageBox.Critical方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_err_windows

# 需要導入模塊: from PyQt5.QtWidgets import QMessageBox [as 別名]
# 或者: from PyQt5.QtWidgets.QMessageBox import Critical [as 別名]
def test_err_windows(qtbot, qapp, pre_text, post_text, expected, caplog):

    def err_window_check():
        w = qapp.activeModalWidget()
        assert w is not None
        try:
            qtbot.add_widget(w)
            if not utils.is_mac:
                assert w.windowTitle() == 'title'
            assert w.icon() == QMessageBox.Critical
            assert w.standardButtons() == QMessageBox.Ok
            assert w.text() == expected
        finally:
            w.close()

    QTimer.singleShot(10, err_window_check)

    with caplog.at_level(logging.ERROR):
        error.handle_fatal_exc(ValueError("exception"), 'title',
                               pre_text=pre_text, post_text=post_text,
                               no_err_windows=False) 
開發者ID:qutebrowser,項目名稱:qutebrowser,代碼行數:23,代碼來源:test_error.py

示例2: test_attributes

# 需要導入模塊: from PyQt5.QtWidgets import QMessageBox [as 別名]
# 或者: from PyQt5.QtWidgets.QMessageBox import Critical [as 別名]
def test_attributes(qtbot):
    """Test basic QMessageBox attributes."""
    title = 'title'
    text = 'text'
    parent = QWidget()
    qtbot.add_widget(parent)
    icon = QMessageBox.Critical
    buttons = QMessageBox.Ok | QMessageBox.Cancel

    box = msgbox.msgbox(parent=parent, title=title, text=text, icon=icon,
                        buttons=buttons)
    qtbot.add_widget(box)
    if not utils.is_mac:
        assert box.windowTitle() == title
    assert box.icon() == icon
    assert box.standardButtons() == buttons
    assert box.text() == text
    assert box.parent() is parent 
開發者ID:qutebrowser,項目名稱:qutebrowser,代碼行數:20,代碼來源:test_msgbox.py

示例3: telegramBotSettings

# 需要導入模塊: from PyQt5.QtWidgets import QMessageBox [as 別名]
# 或者: from PyQt5.QtWidgets.QMessageBox import Critical [as 別名]
def telegramBotSettings(self):
        cfg = ConfigParser()
        cfg.read('./config/telegramBot.cfg', encoding='utf-8-sig')
        read_only = cfg.getboolean('telegramBot', 'read_only')
        # read_only = False
        if read_only:
            text = '基於安全考慮,係統拒絕了本次請求。'
            informativeText = '<b>請聯係設備管理員。</b>'
            CoreUI.callDialog(QMessageBox.Critical, text, informativeText, QMessageBox.Ok)
        else:
            token = cfg.get('telegramBot', 'token')
            chat_id = cfg.get('telegramBot', 'chat_id')
            proxy_url = cfg.get('telegramBot', 'proxy_url')
            message = cfg.get('telegramBot', 'message')

            self.telegramBotDialog = TelegramBotDialog()
            self.telegramBotDialog.tokenLineEdit.setText(token)
            self.telegramBotDialog.telegramIDLineEdit.setText(chat_id)
            self.telegramBotDialog.socksLineEdit.setText(proxy_url)
            self.telegramBotDialog.messagePlainTextEdit.setPlainText(message)
            self.telegramBotDialog.exec()

    # 設備響鈴進程 
開發者ID:winterssy,項目名稱:face_recognition_py,代碼行數:25,代碼來源:core.py

示例4: get_tor_with_prompt

# 需要導入模塊: from PyQt5.QtWidgets import QMessageBox [as 別名]
# 或者: from PyQt5.QtWidgets.QMessageBox import Critical [as 別名]
def get_tor_with_prompt(reactor, parent=None):
    tor = yield get_tor(reactor)
    while not tor:
        msgbox = QMessageBox(parent)
        msgbox.setIcon(QMessageBox.Critical)
        msgbox.setWindowTitle("Tor Required")
        msgbox.setText(
            "This connection can only be made over the Tor network, however, "
            "no running Tor daemon was found or Tor has been disabled."
        )
        msgbox.setInformativeText(
            "Please ensure that Tor is running and try again.<p>For help "
            "installing Tor, visit "
            "<a href=https://torproject.org>https://torproject.org</a>"
        )
        msgbox.setStandardButtons(QMessageBox.Abort | QMessageBox.Retry)
        if msgbox.exec_() == QMessageBox.Retry:
            tor = yield get_tor(reactor)
        else:
            break
    return tor 
開發者ID:gridsync,項目名稱:gridsync,代碼行數:23,代碼來源:tor.py

示例5: handle_fatal_exc

# 需要導入模塊: from PyQt5.QtWidgets import QMessageBox [as 別名]
# 或者: from PyQt5.QtWidgets.QMessageBox import Critical [as 別名]
def handle_fatal_exc(exc: BaseException,
                     title: str, *,
                     no_err_windows: bool,
                     pre_text: str = '',
                     post_text: str = '') -> None:
    """Handle a fatal "expected" exception by displaying an error box.

    If --no-err-windows is given as argument, the text is logged to the error
    logger instead.

    Args:
        exc: The Exception object being handled.
        no_err_windows: Show text in log instead of error window.
        title: The title to be used for the error message.
        pre_text: The text to be displayed before the exception text.
        post_text: The text to be displayed after the exception text.
    """
    if no_err_windows:
        lines = [
            "Handling fatal {} with --no-err-windows!".format(_get_name(exc)),
            "",
            "title: {}".format(title),
            "pre_text: {}".format(pre_text),
            "post_text: {}".format(post_text),
            "exception text: {}".format(str(exc) or 'none'),
        ]
        log.misc.exception('\n'.join(lines))
    else:
        log.misc.exception("Fatal exception:")
        if pre_text:
            msg_text = '{}: {}'.format(pre_text, exc)
        else:
            msg_text = str(exc)
        if post_text:
            msg_text += '\n\n{}'.format(post_text)
        msgbox = QMessageBox(QMessageBox.Critical, title, msg_text)
        msgbox.exec_() 
開發者ID:qutebrowser,項目名稱:qutebrowser,代碼行數:39,代碼來源:error.py

示例6: _die

# 需要導入模塊: from PyQt5.QtWidgets import QMessageBox [as 別名]
# 或者: from PyQt5.QtWidgets.QMessageBox import Critical [as 別名]
def _die(message, exception=None):
    """Display an error message using Qt and quit.

    We import the imports here as we want to do other stuff before the imports.

    Args:
        message: The message to display.
        exception: The exception object if we're handling an exception.
    """
    from PyQt5.QtWidgets import QApplication, QMessageBox
    from PyQt5.QtCore import Qt
    if (('--debug' in sys.argv or '--no-err-windows' in sys.argv) and
            exception is not None):
        print(file=sys.stderr)
        traceback.print_exc()
    app = QApplication(sys.argv)
    if '--no-err-windows' in sys.argv:
        print(message, file=sys.stderr)
        print("Exiting because of --no-err-windows.", file=sys.stderr)
    else:
        if exception is not None:
            message = message.replace('%ERROR%', str(exception))
        msgbox = QMessageBox(QMessageBox.Critical, "qutebrowser: Fatal error!",
                             message)
        msgbox.setTextFormat(Qt.RichText)
        msgbox.resize(msgbox.sizeHint())
        msgbox.exec_()
    app.quit()
    sys.exit(1) 
開發者ID:qutebrowser,項目名稱:qutebrowser,代碼行數:31,代碼來源:earlyinit.py

示例7: set_default

# 需要導入模塊: from PyQt5.QtWidgets import QMessageBox [as 別名]
# 或者: from PyQt5.QtWidgets.QMessageBox import Critical [as 別名]
def set_default(self, attr, attr_name):
        msg = QMessageBox()
        msg.setIcon(QMessageBox.Critical)
        msg.setText(
            "Material "
            + attr_name
            + " property is None.\nDefault values set. Please check values."
        )
        msg.setWindowTitle("Warning")
        msg.exec_()
        setattr(self.mat, attr, type(getattr(Material(), attr))()) 
開發者ID:Eomys,項目名稱:pyleecan,代碼行數:13,代碼來源:DMatSetup.py

示例8: _export_image

# 需要導入模塊: from PyQt5.QtWidgets import QMessageBox [as 別名]
# 或者: from PyQt5.QtWidgets.QMessageBox import Critical [as 別名]
def _export_image(self):
        output_file = self.outputFile_box.text()
        if not any(output_file.endswith(el[0]) for el in self._extension_filters):
            output_file += '.{}'.format(self._extension_filters[0][0])

        try:
            self._plotting_frame.export_image(output_file, self.width_box.value(), self.height_box.value(),
                                              dpi=self.dpi_box.value())
            self.previous_values['width'] = self.width_box.value()
            self.previous_values['height'] = self.height_box.value()
            self.previous_values['dpi'] = self.dpi_box.value()
            self.previous_values['output_file'] = self.outputFile_box.text()
            self.previous_values['writeScriptsAndConfig'] = self.writeScriptsAndConfig.isChecked()

            if self.writeScriptsAndConfig.isChecked():
                output_basename = os.path.splitext(output_file)[0]
                self._write_config_file(output_basename + '.conf')
                self._write_python_script_file(output_basename + '_script.py', output_basename + '.conf', output_file,
                                             self.width_box.value(), self.height_box.value(), self.dpi_box.value())
                self._write_bash_script_file(output_basename + '_script.sh', output_basename + '.conf', output_file,
                                             self.width_box.value(), self.height_box.value(), self.dpi_box.value())

        except PermissionError as error:
            msg = QMessageBox()
            msg.setIcon(QMessageBox.Critical)
            msg.setText("Could not write the file to the given destination.")
            msg.setInformativeText(str(error))
            msg.setWindowTitle("Permission denied")
            msg.exec_() 
開發者ID:robbert-harms,項目名稱:MDT,代碼行數:31,代碼來源:main.py

示例9: _write_example_data

# 需要導入模塊: from PyQt5.QtWidgets import QMessageBox [as 別名]
# 或者: from PyQt5.QtWidgets.QMessageBox import Critical [as 別名]
def _write_example_data(self):
        try:
            mdt.utils.get_example_data(self.outputFile.text())
            msg = QMessageBox()
            msg.setIcon(QMessageBox.Information)
            msg.setText('The MDT example data has been written to {}.'.format(self.outputFile.text()))
            msg.setWindowTitle('Success')
            msg.exec_()
        except IOError as e:
            msg = QMessageBox()
            msg.setIcon(QMessageBox.Critical)
            msg.setText(str(e))
            msg.setWindowTitle("File writing error")
            msg.exec_() 
開發者ID:robbert-harms,項目名稱:MDT,代碼行數:16,代碼來源:qt_main.py

示例10: dcritical

# 需要導入模塊: from PyQt5.QtWidgets import QMessageBox [as 別名]
# 或者: from PyQt5.QtWidgets.QMessageBox import Critical [as 別名]
def dcritical(title, text, detailed_text, parent=None):
        """MessageBox with "Critical" icon"""
        QDetailedMessageBox.dgeneric(title,
                                     text,
                                     detailed_text,
                                     QMessageBox.Critical,
                                     parent) 
開發者ID:FrancescoCeruti,項目名稱:linux-show-player,代碼行數:9,代碼來源:qmessagebox.py

示例11: _alert_missing_borg

# 需要導入模塊: from PyQt5.QtWidgets import QMessageBox [as 別名]
# 或者: from PyQt5.QtWidgets.QMessageBox import Critical [as 別名]
def _alert_missing_borg(self):
        msg = QMessageBox()
        msg.setIcon(QMessageBox.Critical)
        msg.setText(self.tr("No Borg Binary Found"))
        msg.setInformativeText(self.tr("Vorta was unable to locate a usable Borg Backup binary."))
        msg.setStandardButtons(QMessageBox.Ok)
        msg.exec_() 
開發者ID:borgbase,項目名稱:vorta,代碼行數:9,代碼來源:application.py

示例12: msg_box_error

# 需要導入模塊: from PyQt5.QtWidgets import QMessageBox [as 別名]
# 或者: from PyQt5.QtWidgets.QMessageBox import Critical [as 別名]
def msg_box_error(text, *args, **kwargs):
    return msg_box(text, *args, **kwargs, buttons=QMessageBox.Ok, default=QMessageBox.Ok, type=QMessageBox.Critical) 
開發者ID:TuringApp,項目名稱:Turing,代碼行數:4,代碼來源:widgets.py

示例13: show_error_dialog

# 需要導入模塊: from PyQt5.QtWidgets import QMessageBox [as 別名]
# 或者: from PyQt5.QtWidgets.QMessageBox import Critical [as 別名]
def show_error_dialog(message: str, details: str=None):
        """
        Convenience method for showing an error dialog.
        """
        # TODO: i18n
        message_box = QMessageBox(
            QMessageBox.Critical,
            "Error",
            message,
            QMessageBox.Ok,
            None
        )
        if details:
            message_box.setDetailedText(details)
        message_box.exec_() 
開發者ID:autokey,項目名稱:autokey,代碼行數:17,代碼來源:qtapp.py

示例14: excepthook

# 需要導入模塊: from PyQt5.QtWidgets import QMessageBox [as 別名]
# 或者: from PyQt5.QtWidgets.QMessageBox import Critical [as 別名]
def excepthook(excType, excValue, tracebackobj):
    """Rewritten "excepthook" function, to display a message box with details about the exception.
    @param excType exception type
    @param excValue exception value
    @param tracebackobj traceback object
    """
    separator = '-' * 40
    notice = "An unhandled exception has occurred\n"

    tbinfofile = io.StringIO()
    traceback.print_tb(tracebackobj, None, tbinfofile)
    tbinfofile.seek(0)
    tbinfo = tbinfofile.read()
    errmsg = '%s: \n%s' % (str(excType), str(excValue))
    sections = [separator, errmsg, separator, tbinfo]
    msg = '\n'.join(sections)

    # Create a QMessagebox
    error_box = QMessageBox()

    error_box.setText(str(notice)+str(msg))
    error_box.setWindowTitle("Hue-plus - unhandled exception")
    error_box.setIcon(QMessageBox.Critical)
    error_box.setStandardButtons(QMessageBox.Ok)
    error_box.setTextInteractionFlags(Qt.TextSelectableByMouse)

    # Show the window
    error_box.exec_()
    sys.exit(1) 
開發者ID:kusti8,項目名稱:hue-plus,代碼行數:31,代碼來源:hue_ui.py

示例15: findPubKey

# 需要導入模塊: from PyQt5.QtWidgets import QMessageBox [as 別名]
# 或者: from PyQt5.QtWidgets.QMessageBox import Critical [as 別名]
def findPubKey(self):
        printDbg("Computing public key...")
        currSpath = self.ui.edt_spath.value()
        currHwAcc = self.ui.edt_hwAccount.value()
        # Check HW device
        if self.caller.hwStatus != 2:
            myPopUp_sb(self.caller, "crit", 'SPMT - hw device check', "Connect to HW device first")
            printDbg("Unable to connect to hardware device. The device status is: %d" % self.caller.hwStatus)
            return None

        result = self.caller.hwdevice.scanForPubKey(currHwAcc, currSpath, self.isTestnet())

        # Connection pop-up
        warningText = "Unable to find public key. The action was refused on the device or another application "
        warningText += "might have taken over the USB communication with the device.<br><br>"
        warningText += "To continue click the <b>Retry</b> button.\nTo cancel, click the <b>Abort</b> button."
        mBox = QMessageBox(QMessageBox.Critical, "WARNING", warningText, QMessageBox.Retry)
        mBox.setStandardButtons(QMessageBox.Retry | QMessageBox.Abort);

        while result is None:
            ans = mBox.exec_()
            if ans == QMessageBox.Abort:
                return
            # we need to reconnect the device
            self.caller.hwdevice.clearDevice()
            self.caller.hwdevice.initDevice(self.caller.header.hwDevices.currentIndex())

            result = self.caller.hwdevice.scanForPubKey(currHwAcc, currSpath, self.isTestnet())

        mess = "Found public key:\n%s" % result
        myPopUp_sb(self.caller, "info", "SPMT - findPubKey", mess)
        printOK("Public Key: %s" % result)
        self.ui.edt_pubKey.setText(result) 
開發者ID:PIVX-Project,項目名稱:PIVX-SPMT,代碼行數:35,代碼來源:tabMNConf.py


注:本文中的PyQt5.QtWidgets.QMessageBox.Critical方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。