本文整理汇总了Python中qtpy.QtWidgets.QMessageBox.addButton方法的典型用法代码示例。如果您正苦于以下问题:Python QMessageBox.addButton方法的具体用法?Python QMessageBox.addButton怎么用?Python QMessageBox.addButton使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qtpy.QtWidgets.QMessageBox
的用法示例。
在下文中一共展示了QMessageBox.addButton方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Console
# 需要导入模块: from qtpy.QtWidgets import QMessageBox [as 别名]
# 或者: from qtpy.QtWidgets.QMessageBox import addButton [as 别名]
#.........这里部分代码省略.........
return plugin_actions
def register_plugin(self):
"""Register plugin in Spyder's main window"""
self.focus_changed.connect(self.main.plugin_focus_changed)
self.main.add_dockwidget(self)
# Connecting the following signal once the dockwidget has been created:
self.shell.exception_occurred.connect(self.exception_occurred)
def exception_occurred(self, text, is_traceback):
"""Exception ocurred in the internal console.
Show a QMessageBox or the internal console to warn the user"""
# Skip errors without traceback
if not is_traceback and self.msgbox_traceback is None:
return
if CONF.get('main', 'show_internal_console_if_traceback', False):
self.dockwidget.show()
self.dockwidget.raise_()
else:
if self.msgbox_traceback is None:
self.msgbox_traceback = QMessageBox(
QMessageBox.Critical,
_('Error'),
_("<b>Spyder has encountered a problem.</b><br>"
"Sorry for the inconvenience."
"<br><br>"
"You can automatically submit this error to our Github "
"issues tracker.<br><br>"
"<i>Note:</i> You need a Github account for that."),
QMessageBox.Ok,
parent=self)
self.submit_btn = self.msgbox_traceback.addButton(
_('Submit to Github'), QMessageBox.YesRole)
self.submit_btn.pressed.connect(self.press_submit_btn)
self.msgbox_traceback.setWindowModality(Qt.NonModal)
self.error_traceback = ""
self.msgbox_traceback.show()
self.msgbox_traceback.finished.connect(self.close_msg)
self.msgbox_traceback.setDetailedText(' ')
# open show details (iterate over all buttons and click it)
for button in self.msgbox_traceback.buttons():
if (self.msgbox_traceback.buttonRole(button)
== QMessageBox.ActionRole):
button.click()
break
self.error_traceback += text
self.msgbox_traceback.setDetailedText(self.error_traceback)
def close_msg(self):
self.msgbox_traceback = None
def press_submit_btn(self):
self.main.report_issue(self.error_traceback)
self.msgbox_traceback = None
#------ Public API ---------------------------------------------------------
@Slot()
def quit(self):
"""Quit mainwindow"""
self.main.close()