from PyQt5.QtWidgets import QLabel, QApplication app = QApplication([]) label = QLabel('Hello World') label.show() app.exec_()
from PyQt5.QtWidgets import QLabel, QApplication from PyQt5.QtGui import QPixmap app = QApplication([]) label = QLabel() pixmap = QPixmap('image.jpg') label.setPixmap(pixmap) label.show() app.exec_()In this example, we create a QLabel object and set it to display an image using QPixmap. We load the image from a file using the QPixmap constructor and then set the pixmap with the setPixmap() method of the QLabel object. Package library: PyQt5.