How to put an event on the buttons of QMessageBox

I just want to set an event on the yes button of the message box but when I click the yes button it return me None value.

def question(self):
    msg = QMessageBox()
    result = msg.setStandardButtons(msg.Yes | msg.No)
    msg.setIcon(msg.Question)
    msg.setText(self.text)
    msg.setWindowTitle('Console')

    if result == msg.Yes:
        print('Yes')

    msg.exec_()


Read more here: https://stackoverflow.com/questions/68487475/how-to-put-an-event-on-the-buttons-of-qmessagebox

Content Attribution

This content was originally published by Piolo Torrecampo at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: