本文整理汇总了Python中AnyQt.QtWidgets.QMessageBox.setDefaultButton方法的典型用法代码示例。如果您正苦于以下问题:Python QMessageBox.setDefaultButton方法的具体用法?Python QMessageBox.setDefaultButton怎么用?Python QMessageBox.setDefaultButton使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AnyQt.QtWidgets.QMessageBox
的用法示例。
在下文中一共展示了QMessageBox.setDefaultButton方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: message
# 需要导入模块: from AnyQt.QtWidgets import QMessageBox [as 别名]
# 或者: from AnyQt.QtWidgets.QMessageBox import setDefaultButton [as 别名]
def message(icon, text, title=None, informative_text=None, details=None,
buttons=None, default_button=None, exc_info=False, parent=None):
"""Show a message helper function.
"""
if title is None:
title = "Message"
if not text:
text = "I am neither a postman nor a doctor."
if buttons is None:
buttons = QMessageBox.Ok
if details is None and exc_info:
details = traceback.format_exc(limit=20)
mbox = QMessageBox(icon, title, text, buttons, parent)
if informative_text:
mbox.setInformativeText(informative_text)
if details:
mbox.setDetailedText(details)
if default_button is not None:
mbox.setDefaultButton(default_button)
return mbox.exec_()
示例2: show_survey
# 需要导入模块: from AnyQt.QtWidgets import QMessageBox [as 别名]
# 或者: from AnyQt.QtWidgets.QMessageBox import setDefaultButton [as 别名]
def show_survey():
# If run for the first time, open a browser tab with a survey
settings = QSettings()
show_survey = settings.value("startup/show-survey", True, type=bool)
if show_survey:
question = QMessageBox(
QMessageBox.Question,
'Orange Survey',
'We would like to know more about how our software is used.\n\n'
'Would you care to fill our short 1-minute survey?',
QMessageBox.Yes | QMessageBox.No)
question.setDefaultButton(QMessageBox.Yes)
later = question.addButton('Ask again later', QMessageBox.NoRole)
question.setEscapeButton(later)
def handle_response(result):
if result == QMessageBox.Yes:
success = QDesktopServices.openUrl(
QUrl("https://orange.biolab.si/survey/short.html"))
settings.setValue("startup/show-survey", not success)
else:
settings.setValue("startup/show-survey", result != QMessageBox.No)
question.finished.connect(handle_response)
question.show()
return question
示例3: message_restart
# 需要导入模块: from AnyQt.QtWidgets import QMessageBox [as 别名]
# 或者: from AnyQt.QtWidgets.QMessageBox import setDefaultButton [as 别名]
def message_restart(parent):
icon = QMessageBox.Information
buttons = QMessageBox.Ok | QMessageBox.Cancel
title = 'Information'
text = 'Orange needs to be restarted for the changes to take effect.'
msg_box = QMessageBox(icon, title, text, buttons, parent)
msg_box.setDefaultButton(QMessageBox.Ok)
msg_box.setInformativeText('Press OK to close Orange now.')
msg_box.button(QMessageBox.Cancel).setText('Close later')
return msg_box.exec_()
示例4: compare_versions
# 需要导入模块: from AnyQt.QtWidgets import QMessageBox [as 别名]
# 或者: from AnyQt.QtWidgets.QMessageBox import setDefaultButton [as 别名]
def compare_versions(latest):
version = pkg_resources.parse_version
if version(latest) <= version(current):
return
question = QMessageBox(
QMessageBox.Information,
'Orange Update Available',
'A newer version of Orange is available.<br><br>'
'<b>Current version:</b> {}<br>'
'<b>Latest version:</b> {}'.format(current, latest),
textFormat=Qt.RichText)
ok = question.addButton('Download Now', question.AcceptRole)
question.setDefaultButton(ok)
question.addButton('Remind Later', question.RejectRole)
question.finished.connect(
lambda:
question.clickedButton() == ok and
QDesktopServices.openUrl(QUrl("https://orange.biolab.si/download/")))
question.show()
示例5: main
# 需要导入模块: from AnyQt.QtWidgets import QMessageBox [as 别名]
# 或者: from AnyQt.QtWidgets.QMessageBox import setDefaultButton [as 别名]
#.........这里部分代码省略.........
cache_filename = os.path.join(cache_dir(), "widget-registry.pck")
if options.no_discovery:
widget_registry = pickle.load(open(cache_filename, "rb"))
widget_registry = qt.QtWidgetRegistry(widget_registry)
else:
widget_discovery.run(config.widgets_entry_points())
# Store cached descriptions
cache.save_registry_cache(widget_discovery.cached_descriptions)
pickle.dump(WidgetRegistry(widget_registry),
open(cache_filename, "wb"))
set_global_registry(widget_registry)
canvas_window.set_widget_registry(widget_registry)
canvas_window.show()
canvas_window.raise_()
want_welcome = \
settings.value("startup/show-welcome-screen", True, type=bool) \
and not options.no_welcome
# Process events to make sure the canvas_window layout has
# a chance to activate (the welcome dialog is modal and will
# block the event queue, plus we need a chance to receive open file
# signals when running without a splash screen)
app.processEvents()
app.fileOpenRequest.connect(canvas_window.open_scheme_file)
if want_welcome and not args and not open_requests:
canvas_window.welcome_dialog()
elif args:
log.info("Loading a scheme from the command line argument %r",
args[0])
canvas_window.load_scheme(args[0])
elif open_requests:
log.info("Loading a scheme from an `QFileOpenEvent` for %r",
open_requests[-1])
canvas_window.load_scheme(open_requests[-1].toLocalFile())
# If run for the first time, open a browser tab with a survey
show_survey = settings.value("startup/show-survey", True, type=bool)
if show_survey:
question = QMessageBox(
QMessageBox.Question,
'Orange Survey',
'We would like to know more about how our software is used.\n\n'
'Would you care to fill our short 1-minute survey?',
QMessageBox.Yes | QMessageBox.No)
question.setDefaultButton(QMessageBox.Yes)
later = question.addButton('Ask again later', QMessageBox.NoRole)
question.setEscapeButton(later)
def handle_response(result):
if result == QMessageBox.Yes:
success = QDesktopServices.openUrl(
QUrl("http://orange.biolab.si/survey/short.html"));
settings.setValue("startup/show-survey", not success)
else:
settings.setValue("startup/show-survey", result != QMessageBox.No)
question.finished.connect(handle_response)
question.show()
# Tee stdout and stderr into Output dock
log_view = canvas_window.log_view()
stdout = TextStream()
stdout.stream.connect(log_view.write)
if sys.stdout:
stdout.stream.connect(sys.stdout.write)
stdout.flushed.connect(sys.stdout.flush)
stderr = TextStream()
error_writer = log_view.formated(color=Qt.red)
stderr.stream.connect(error_writer.write)
if sys.stderr:
stderr.stream.connect(sys.stderr.write)
stderr.flushed.connect(sys.stderr.flush)
log.info("Entering main event loop.")
try:
with patch('sys.excepthook',
ExceptHook(stream=stderr, canvas=canvas_window,
handledException=handle_exception)),\
patch('sys.stderr', stderr),\
patch('sys.stdout', stdout):
status = app.exec_()
except BaseException:
log.error("Error in main event loop.", exc_info=True)
canvas_window.deleteLater()
app.processEvents()
app.flush()
del canvas_window
# Collect any cycles before deleting the QApplication instance
gc.collect()
del app
return status