Label
1from PyQt5.QtWidgets import (
2 QMainWindow, QApplication, QLabel
3)
4
5class MainWindow(QMainWindow, object):
6 def __init__(self, parent=None):
7 super(MainWindow, self).__init__(parent)
8 # Create a label
9 self.label = QLabel("This is a label!", self)
10 # Set the position of the label
11 self.label.move(50, 50)
12
13if __name__ == "__main__":
14 app = QApplication([])
15 mainWindow = MainWindow()
16 mainWindow.show()
17 app.exec_()
This example adds a
QLabelwidget to the basic window to display a text label.QLabelis used to display simple text or images.