How to display variable in qmessagebox using creator in pyqt5

Viewed 1262

I am trying to display a variable with some message in qmessagebox using creator. I found similar post here: pyqt: Variable values in QMessageBox output? but it does not work within the creator. Any suggestions how to amend the code below so that it worked?:

purchaseValue = col2SumUp.sum()
msgbox = QMessageBox(QMessageBox.Information, "Value: %s" % purchaseValue, QMessageBox.Ok)
1 Answers

You are missing the title parameter, the following is working for me:

purchaseValue = 125.2
msgbox = QMessageBox(QMessageBox.Information, "Title", "Value: %s" % purchaseValue, QMessageBox.Ok)
msgbox.exec_()

QMessageBox

Related