Hello World with PyQt and Python.
Create project and install PyQt
This example is written on MacOS but should work on Windows and Linux. Start by opening a terminal and create a project:
mkdir helloworld cd helloworld
Create a virtual environment and install PyQt5 in it:
python3 -m venv env source env/bin/activate pip install pyqt5
main.py and enter:
import sys from PyQt5.QtWidgets import QApplication, QMainWindow, QLabel app = QApplication(sys.argv) window = QMainWindow() window.setWindowTitle("Hello World") label = QLabel('I must have left my house at 8, because I always do.') label.setMargin(20) window.setCentralWidget(label) window.show() app.exec_()
Start the app in the Terminal with:
The result should look like this.