I seem to be hitting a brick wall. No matter what I do, creating a critical error Message Box just doesn\'t seem to be working. Here\'s what I\'ve tried thus far:
Here's an example from Qt.Gitorious.
from PySide import QtGui, QtCore
import sys
class Dialog(QtGui.QDialog):
MESSAGE = QtCore.QT_TR_NOOP("Message boxes have a caption, a text, and up to "
"three buttons, each with standard or custom texts.
"
"Click a button or press Esc.
")
def __init__(self, parent=None):
QtGui.QDialog.__init__(self, parent)
self.criticalLabel = QtGui.QLabel()
self.criticalLabel.setFrameStyle(QtGui.QFrame.Sunken | QtGui.QFrame.Panel)
self.criticalButton = QtGui.QPushButton(self.tr("QMessageBox.critica&l()"))
layout = QtGui.QGridLayout()
layout.addWidget(self.criticalButton, 10, 0)
layout.addWidget(self.criticalLabel, 10, 1)
self.setLayout(layout)
self.connect(self.criticalButton, QtCore.SIGNAL("clicked()"), self.criticalMessage)
def criticalMessage(self):
reply = QtGui.QMessageBox.critical(self, self.tr("QMessageBox.showCritical()"),
Dialog.MESSAGE, QtGui.QMessageBox.Abort|
QtGui.QMessageBox.StandardButton.Retry|
QtGui.QMessageBox.StandardButton.Ignore)
if reply == QtGui.QMessageBox.Abort:
self.criticalLabel.setText(self.tr("Abort"))
elif reply == QtGui.QMessageBox.Retry:
self.criticalLabel.setText(self.tr("Retry"))
else:
self.criticalLabel.setText(self.tr("Ignore"))
if __name__ == '__main__':
app = QtGui.QApplication(sys.argv)
dialog = Dialog()
sys.exit(dialog.exec_())
To answer your question you can check the documentation:
static PySide.QtGui.QMessageBox.critical(parent, title, text[, buttons=QMessageBox.Ok[, defaultButton=NoButton]])
In the example, parent = self, title = self.tr("QMessageBox.showCritical()"), text = Dialog.MESSAGE, buttons = QtGui.QMessageBox.Abort | QtGui.QMessageBox.StandardButton.Retry | QtGui.QMessageBox.StandardButton.Ignore
The tr is just some Qt function to set up translations, basically its a string. I can't really tell you what you did wrong, looking at the error message, it seems to have parsed things wrong. Possibly because of the way you assigned values to flags.
The example also shows how to deal with the result of the critical dialog, which seems useful.