當前位置: 首頁>>代碼示例>>Python>>正文


Python QMessageBox.setText方法代碼示例

本文整理匯總了Python中PyQt5.Qt.QMessageBox.setText方法的典型用法代碼示例。如果您正苦於以下問題:Python QMessageBox.setText方法的具體用法?Python QMessageBox.setText怎麽用?Python QMessageBox.setText使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在PyQt5.Qt.QMessageBox的用法示例。


在下文中一共展示了QMessageBox.setText方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: QuestionDialog

# 需要導入模塊: from PyQt5.Qt import QMessageBox [as 別名]
# 或者: from PyQt5.Qt.QMessageBox import setText [as 別名]
def QuestionDialog(title, text, info = None, dontAsk = False):
    msgBox = QMessageBox()

    buttonYes = msgBox.addButton(_("Yes"), QMessageBox.ActionRole)
    buttonNo = msgBox.addButton(_("No"), QMessageBox.ActionRole)

    answers = {buttonYes:"yes",
               buttonNo :"no"}
    if dontAsk:
        buttonDontAsk = msgBox.addButton(_("Don't ask again"), QMessageBox.ActionRole)
        answers[buttonDontAsk] = "dontask"

    msgBox.setText(text)
    if not info:
        info = _("Do you want to continue?")
    msgBox.setInformativeText(info)

    dialog = Dialog(_(title), msgBox, closeButton = False, isDialog = True, icon="question")
    dialog.resize(300,120)
    dialog.exec_()

    ctx.mainScreen.processEvents()
    if msgBox.clickedButton() in answers.keys():
        return answers[msgBox.clickedButton()]
    return "no"
開發者ID:MusaSakizci,項目名稱:yali-family,代碼行數:27,代碼來源:YaliDialog.py

示例2: show_warning

# 需要導入模塊: from PyQt5.Qt import QMessageBox [as 別名]
# 或者: from PyQt5.Qt.QMessageBox import setText [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()
開發者ID:wordtinker,項目名稱:SimpleBudget,代碼行數:11,代碼來源:utils.py

示例3: InfoDialog

# 需要導入模塊: from PyQt5.Qt import QMessageBox [as 別名]
# 或者: from PyQt5.Qt.QMessageBox import setText [as 別名]
def InfoDialog(text, button=None, title=None, icon="info"):
    if not title:
        title = _("Information")
    if not button:
        button = _("OK")

    msgBox = QMessageBox()

    buttonOk = msgBox.addButton(button, QMessageBox.ActionRole)

    msgBox.setText(text)

    dialog = Dialog(_(title), msgBox, closeButton = False, isDialog = True, icon = icon)
    dialog.resize(300,120)
    dialog.exec_()
    ctx.mainScreen.processEvents()
開發者ID:MusaSakizci,項目名稱:yali-family,代碼行數:18,代碼來源:YaliDialog.py

示例4: _save_dialog

# 需要導入模塊: from PyQt5.Qt import QMessageBox [as 別名]
# 或者: from PyQt5.Qt.QMessageBox import setText [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_()
開發者ID:aimylios,項目名稱:calibre,代碼行數:8,代碼來源:custom_column_widgets.py

示例5: __init__

# 需要導入模塊: from PyQt5.Qt import QMessageBox [as 別名]
# 或者: from PyQt5.Qt.QMessageBox import setText [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
開發者ID:MusaSakizci,項目名稱:yali-family,代碼行數:84,代碼來源:YaliDialog.py

示例6: step_dialog

# 需要導入模塊: from PyQt5.Qt import QMessageBox [as 別名]
# 或者: from PyQt5.Qt.QMessageBox import setText [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
開發者ID:davidfor,項目名稱:calibre,代碼行數:8,代碼來源:device_user_defined.py


注:本文中的PyQt5.Qt.QMessageBox.setText方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。