Last active
December 20, 2015 21:19
-
-
Save ivoflipse/6197205 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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