May 2019
Intermediate to advanced
542 pages
13h 37m
English
QLabel is a QWidget object configured to display simple text and images.
Creating one looks like this:
label = qtw.QLabel('Hello Widgets!', self)
Notice this time that the parent widget is specified as the second argument, while the first argument is the text of the label.
Some commonly used QLabel properties are shown here:
| Property | Argument | Description |
|---|---|---|
| text | string | Text to display on the label. |
| margin | integer | Space (in pixels) around the text. |
| indent | integer | Space (in pixels) to indent the text. |
| wordWrap | Boolean | Whether to wrap long lines. |
| textFormat | Qt.TextFormat | Force plaintext or rich text, or auto-detect. |
| pixmap | QPixmap | An image to display instead of the text. |
The label's text is stored in its text property ...
Read now
Unlock full access