本文整理汇总了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)
示例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
示例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()
# 设备响铃进程
示例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
示例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_()
示例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)
示例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))())
示例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_()
示例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_()
示例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)
示例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_()
示例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)
示例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_()
示例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)
示例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)