本文整理汇总了Python中AnyQt.QtWidgets.QMessageBox.exec_方法的典型用法代码示例。如果您正苦于以下问题:Python QMessageBox.exec_方法的具体用法?Python QMessageBox.exec_怎么用?Python QMessageBox.exec_使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AnyQt.QtWidgets.QMessageBox
的用法示例。
在下文中一共展示了QMessageBox.exec_方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: save_plot
# 需要导入模块: from AnyQt.QtWidgets import QMessageBox [as 别名]
# 或者: from AnyQt.QtWidgets.QMessageBox import exec_ [as 别名]
def save_plot(data, file_formats, filename=""):
_LAST_DIR_KEY = "directories/last_graph_directory"
_LAST_FILTER_KEY = "directories/last_graph_filter"
settings = QSettings()
start_dir = settings.value(_LAST_DIR_KEY, filename)
if not start_dir or \
(not os.path.exists(start_dir) and
not os.path.exists(os.path.split(start_dir)[0])):
start_dir = os.path.expanduser("~")
last_filter = settings.value(_LAST_FILTER_KEY, "")
filename, writer, filter = \
filedialogs.open_filename_dialog_save(start_dir, last_filter, file_formats)
if not filename:
return
try:
writer.write(filename, data)
except OSError as e:
mb = QMessageBox(
None,
windowTitle="Error",
text='Error occurred while saving file "{}": {}'.format(filename, e),
detailedText=traceback.format_exc(),
icon=QMessageBox.Critical)
mb.exec_()
else:
settings.setValue(_LAST_DIR_KEY, os.path.split(filename)[0])
settings.setValue(_LAST_FILTER_KEY, filter)
示例2: message
# 需要导入模块: from AnyQt.QtWidgets import QMessageBox [as 别名]
# 或者: from AnyQt.QtWidgets.QMessageBox import exec_ [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_()
示例3: track_user_stats
# 需要导入模块: from AnyQt.QtWidgets import QMessageBox [as 别名]
# 或者: from AnyQt.QtWidgets.QMessageBox import exec_ [as 别名]
def track_user_stats():
reply = get_usage_track_conf()
if reply=='ask later':
m = QMessageBox(
QMessageBox.Question,
"User tracking",
"Do you give us permission to track which country you are from and how many times you use this application? " \
"This will contribute to the support of this software.",
QMessageBox.Yes | QMessageBox.No | QMessageBox.NoRole
)
ask_later_btn = m.addButton("Ask me later", QMessageBox.NoRole)
m.setEscapeButton(ask_later_btn)
reply = m.exec_()
if reply == QMessageBox.No:
set_usage_track_conf('no-track')
elif reply == QMessageBox.Yes:
set_usage_track_conf('track')
reply = 'track'
elif reply == QMessageBox.NoButton:
set_usage_track_conf('ask later')
if reply=='track':
register_access()
示例4: message_restart
# 需要导入模块: from AnyQt.QtWidgets import QMessageBox [as 别名]
# 或者: from AnyQt.QtWidgets.QMessageBox import exec_ [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_()
示例5: start
# 需要导入模块: from AnyQt.QtWidgets import QMessageBox [as 别名]
# 或者: from AnyQt.QtWidgets.QMessageBox import exec_ [as 别名]
def start():
try:
pyforms.start_app(
VideoAnnotator,
geometry=conf.MAIN_WINDOW_GEOMETRY
)
except Exception as e:
report = traceback.format_exc()
app = QApplication(sys.argv)
m = QMessageBox(
QMessageBox.Question,
"Send report",
"<h2>Would you like to send us a report of the bug?</h2>"
"This will help us improving the software."
"<p>{bug}</p>".format( bug=str(e) ),
QMessageBox.Yes | QMessageBox.No
)
reply = m.exec_()
if reply==QMessageBox.Yes:
try:
app_id = conf.USERSTATS_APP_ID
reg_id = get_mac()
os_name = platform.platform()
version = pythonvideoannotator.__version__
data = {'app-id': app_id, 'reg-id': reg_id, 'os-name' : os_name, 'version': version, 'report': report}
url = "{}/register-bug".format(conf.USERSTATS_URL)
request = Request(url, urlencode(data).encode())
urlopen(request).read().decode()
except Exception as ex:
print("Could not register new access", ex )
exit()
app.exec_()