import sys from PyQt5.QtWidgets import QApplication, QLabel app = QApplication(sys.argv) label = QLabel('Hello World!') label.show() sys.exit(app.exec_())
import sys from PyQt5.QtWidgets import QApplication, QLabel from PyQt5.QtGui import QPixmap app = QApplication(sys.argv) label = QLabel() pixmap = QPixmap('image.jpg') label.setPixmap(pixmap) label.show() sys.exit(app.exec_())In this example, we create a QLabel object and load an image using QPixmap. We then set the pixmap on the QLabel object using `setPixmap()` function. The image is then displayed by calling the `show()` function. Overall, PyQt5.QtWidgets package provides a number of versatile widgets for creating graphical user interfaces in Python applications.