1# in pyqt5 it needs to be PyQt5.QtWidgets
2msg=QMessageBox() # create an instance of it
3msg.setIcon(QMessageBox.Information) # set icon
4msg.setText("This is a message box") # set text
5msg.setInformativeText("This is additional information") # set information under the main text
6msg.setWindowTitle("MessageBox demo") # set title
7msg.setDetailedText("The details are as follows:") # a button for more details will add in
8msg.setStandardButtons(QMessageBox.Ok | QMessageBox.Cancel) # type of buttons associated
9msg.buttonClicked.connect(myfunc) # connect clicked signal
10return_value =msg.exec_() # get the return value
11print("value of pressed message box button:", str(return_value)) # print result
12