How to change the name of the standard buttons?

How to setInformativeText add a picture?

Code:

 msg = QMessageBox() msg.setWindowTitle("Информация") msg.setText("Privet") msg.setInformativeText("dfgdfgdg") msg.setDetailedText("dgdfg23") result = msg.setStandardButtons(QMessageBox.Ok | QMessageBox.Cancel) retval = msg.exec_() if retval == QMessageBox.Ok: print("Yes") else: print("No") 

    1 answer 1

    The easiest option:

     msg = QMessageBox() msg.setIcon(QMessageBox.Information) # msg.setIconPixmap(pixmap) # Своя картинка msg.setWindowTitle("Информация") msg.setText("Privet") msg.setInformativeText("InformativeText") msg.setDetailedText("DetailedText") okButton = msg.addButton('Окей', QMessageBox.AcceptRole) msg.addButton('Отмена', QMessageBox.RejectRole) msg.exec() if msg.clickedButton() == okButton: print("Yes") else: print("No") 

    enter image description here


    The hard way is to find Qt translation files (seemingly like .qm ), get acquainted with the QTranslator class and load the translation file, then the standard names will be replaced

    • Is it possible to put a picture instead of text in msg.setInformativeText("InformativeText") ?? - user222349
    • @fangry, aha, dirty hack, replacing the widget, so it’s better to take QDialog and throw widgets you need on it - you will not notice the difference - gil9red