Ejemplo n.º 1
0
def confirmationBox(text,info_text,object_name="confirmationBox"):
    """ Show a confirmation box to the user.

    :param text: Summary of the confirmation.
    :param info_text: Detailed message explaining what to confirm
    :param object_name: Name for Qt's object.
    :return: True if the user confirmed. False else.
    """

    box = QMessageBox()
    box.setObjectName(object_name)
    box.setWindowTitle(_("Please confirm"))
    box.setIcon(QMessageBox.Question)
    _setBoxTexts(box,text,info_text)
    box.setStandardButtons(QMessageBox.Ok | QMessageBox.Cancel);

    # box.show()
    # from PySide.QtTest import QTest
    # from PySide.QtGui import QApplication
    # QTest.qWaitForWindowShown(box)
    # QApplication.instance().removePostedEvents()

    r = box.exec_() == QMessageBox.Ok

    box.deleteLater()
    return r
Ejemplo n.º 2
0
def yesNoBox(text,info_text,object_name="confirmationBox"):
    warningBox = QMessageBox()
    warningBox.setObjectName(object_name)
    warningBox.setWindowTitle(_("Please confirm"))
    warningBox.setIcon(QMessageBox.Question)
    _setBoxTexts(warningBox,text,info_text)
    warningBox.setStandardButtons(QMessageBox.Yes | QMessageBox.No | QMessageBox.Cancel);
    return warningBox.exec_()
Ejemplo n.º 3
0
def makeWarningBox(text,info_text,parent=None):
    warningBox = QMessageBox(parent)
    warningBox.setObjectName("warning_box")
    warningBox.setWindowTitle(_("Warning !"))
    warningBox.setIcon(QMessageBox.Warning)
    _setBoxTexts(warningBox,text,info_text)
    warningBox.setStandardButtons(QMessageBox.Ok);
    return warningBox
Ejemplo n.º 4
0
def confirmationBox(text, info_text, object_name="confirmationBox"):
    box = QMessageBox()
    box.setObjectName(object_name)
    box.setWindowTitle(_("Please confirm"))
    box.setIcon(QMessageBox.Question)
    box.setText(text)
    if info_text:
        box.setInformativeText(info_text)
    box.setStandardButtons(QMessageBox.Ok | QMessageBox.Cancel)

    # box.show()
    # from PySide.QtTest import QTest
    # from PySide.QtGui import QApplication
    # QTest.qWaitForWindowShown(box)
    # QApplication.instance().removePostedEvents()

    r = box.exec_() == QMessageBox.Ok

    box.deleteLater()
    return r
Ejemplo n.º 5
0
def makeErrorBox(text,info_text = None,ex=None):
    mainlog.warning("makeErrorBox : {}".format(text))
    errorBox = QMessageBox()
    errorBox.setObjectName("error_box")
    errorBox.setWindowTitle(_("Error !"))
    errorBox.setIcon(QMessageBox.Critical)

    t = info_text
    if ex:
        nfo = ""
        if info_text:
            nfo = info_text + u'\n'
        t = u"{}{}\n{}".format(nfo,_("Additional information :"), str(ex))
    _setBoxTexts(errorBox,text,t)
    errorBox.setStandardButtons(QMessageBox.Ok)

    if ex:
        log_stacktrace()
        mainlog.exception(ex)
    return errorBox