Skip to content

Instantly share code, notes, and snippets.

@ivoflipse
Last active December 20, 2015 21:19
Show Gist options
  • Save ivoflipse/6197205 to your computer and use it in GitHub Desktop.
Save ivoflipse/6197205 to your computer and use it in GitHub Desktop.
from PySide import QtGui, QtCore
import sys
class Dialog(QtGui.QDialog):
MESSAGE = QtCore.QT_TR_NOOP("<p>Message boxes have a caption, a text, and up to "
"three buttons, each with standard or custom texts.</p>"
"<p>Click a button or press Esc.</p>")
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_())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment