I am coding a application which needs a custom buttons in QMessageBox. i managed to create an example in QT designer which is given below.
i wanted to do this in a QMessageBox.
I am using python 2.6.4 and PyQt4. please, can any one help.
manuel-gutierrez, why do you inherit from QDilaog? You can inherit from QMessageBox. It's much simpler and less code
import sys
from PyQt4.QtGui import QMessageBox, QPushButton, QApplication
from PyQt4.QtCore import Qt
class ErrorWindow(QMessageBox):
def __init__(self, parent=None):
QMessageBox.__init__(self, parent)
self.setWindowTitle("Example")
self.addButton(QPushButton("Yes"), QMessageBox.YesRole )
self.addButton(QPushButton("No"), QMessageBox.NoRole)
self.addButton(QPushButton("Cancel"), QMessageBox.RejectRole)
if __name__ == "__main__":
app = QApplication(sys.argv)
ex = ErrorWindow()
ex.setText("some error")
ex.show()
sys.exit(app.exec_())
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With