本文整理汇总了Python中PyQt5.Qt.QMessageBox.setStandardButtons方法的典型用法代码示例。如果您正苦于以下问题:Python QMessageBox.setStandardButtons方法的具体用法?Python QMessageBox.setStandardButtons怎么用?Python QMessageBox.setStandardButtons使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.Qt.QMessageBox
的用法示例。
在下文中一共展示了QMessageBox.setStandardButtons方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: show_warning
# 需要导入模块: from PyQt5.Qt import QMessageBox [as 别名]
# 或者: from PyQt5.Qt.QMessageBox import setStandardButtons [as 别名]
def show_warning(text):
"""
Shows a simple warning with given text.
"""
msg_box = QMessageBox()
msg_box.setText(text)
msg_box.setStandardButtons(QMessageBox.Ok)
msg_box.setDefaultButton(QMessageBox.Ok)
msg_box.exec()
示例2: _save_dialog
# 需要导入模块: from PyQt5.Qt import QMessageBox [as 别名]
# 或者: from PyQt5.Qt.QMessageBox import setStandardButtons [as 别名]
def _save_dialog(self, parent, title, msg, det_msg=''):
d = QMessageBox(parent)
d.setWindowTitle(title)
d.setText(msg)
d.setStandardButtons(QMessageBox.Yes | QMessageBox.No | QMessageBox.Cancel)
return d.exec_()
示例3: __init__
# 需要导入模块: from PyQt5.Qt import QMessageBox [as 别名]
# 或者: from PyQt5.Qt.QMessageBox import setStandardButtons [as 别名]
class MessageWindow:
def __init__(self, title, text, type="ok", default=None, customButtons =None, customIcon=None, run=True, destroyAfterRun=True, detailed=False, longText=""):
self.rc = None
self.dialog = None
self.msgBox = QMessageBox()
self.doCustom = False
self.customButtons = customButtons
icon = None
buttons = None
if type == 'ok':
buttons = QMessageBox.Ok
icon = "question"
elif type == 'error':
icon = "error"
buttons = QMessageBox.Ok
elif type == 'warning':
icon = "warning"
buttons = QMessageBox.Ok
elif type == 'okcancel':
icon = "question"
buttons = QMessageBox.Ok | QMessageBox.Cancel
elif type == 'question':
icon = "question"
buttons = QMessageBox.Ok | QMessageBox.Cancel
elif type == 'yesno':
icon = "question"
buttons = QMessageBox.Yes | QMessageBox.No
elif type == 'custom':
self.doCustom = True
if customIcon:
icon = customIcon
else:
icon = "question"
text = "<qt>%s</qt>" % text.replace("\n", " ")
self.msgBox.setText(text)
if detailed:
self.msgBox.setDetailedText(unicode(longText))
if self.doCustom:
button = None
for index, text in enumerate(self.customButtons):
button = self.msgBox.addButton(text, QMessageBox.ActionRole)
if default is not None and default == index:
self.msgBox.setDefaultButton(button)
else:
self.msgBox.setStandardButtons(buttons)
if default == "no":
default = QMessageBox.No
elif default == "yes":
default = QMessageBox.Yes
elif default == "ok":
default = QMessageBox.Ok
else:
default = None
self.msgBox.setDefaultButton(default)
self.dialog = Dialog(_(title), self.msgBox, closeButton=False, isDialog=True, icon=icon)
self.dialog.resize(QSize(0,0))
if run:
self.run(destroyAfterRun)
def run(self, destroyAfterRun=True):
self.rc = self.dialog.exec_()
if self.msgBox.clickedButton():
if not self.doCustom:
if self.msgBox.clickedButton().text() in [_("Ok"), _("Yes")]:
self.rc = 1
elif self.msgBox.clickedButton().text() in [_("Cancel"), _("No")]:
self.rc = 0
else:
if self.msgBox.clickedButton().text() in self.customButtons:
self.rc = self.customButtons.index(self.msgBox.clickedButton().text())
if destroyAfterRun:
self.dialog = None
return self.rc
示例4: step_dialog
# 需要导入模块: from PyQt5.Qt import QMessageBox [as 别名]
# 或者: from PyQt5.Qt.QMessageBox import setStandardButtons [as 别名]
def step_dialog(parent, title, msg, det_msg=''):
d = QMessageBox(parent)
d.setWindowTitle(title)
d.setText(msg)
d.setStandardButtons(QMessageBox.Ok | QMessageBox.Cancel)
return d.exec_() & QMessageBox.Cancel