How to use the PyQt5 library in Python

1. Install the PyQt5 library using the pip install command:

pip install PyQt5

2. Import the necessary modules from the library:

from PyQt5 import QtCore, QtGui, QtWidgets

3. Create a QApplication instance:

app = QtWidgets.QApplication(sys.argv)

4. Create the main window:

mainWindow = QtWidgets.QMainWindow()

5. Create widgets and set their properties:

label = QtWidgets.QLabel(„Hello World!”)
label.setAlignment(QtCore.Qt.AlignCenter)

6. Add the widgets to the main window:

mainWindow.setCentralWidget(label)

7. Show the main window:

mainWindow.show()

8. Execute the application:

sys.exit(app.exec_())