Qt for Python Tutorial HelloQMessageBox
PySide2 Hello World using a QMessageBox
This is a very simple "Hello World" script for PySide2. Simply copy&paste it into a file, and execute it.
1 #!/usr/bin/python 2 3 import sys 4 from PySide2.QtWidgets import QApplication, QMessageBox 5 6 # Create the application object 7 app = QApplication(sys.argv) 8 9 # Create a simple dialog box 10 msg_box = QMessageBox() 11 msg_box.setText("Hello World!") 12 msg_box.show() 13 14 sys.exit(msg_box.exec_())
Note that in this example, we are creating a QApplication even though we are not directly executing it, this is because a QMessageBox is being executed independently.