While creating a Label in PyQt5, we can see that there is no background color. In this article we will see how to add background color to the Label.
In order to add border to the Label we will use
label.setStyleSheet() method, this will add the background color to the label, it is same like designing the CSS style sheet.
Syntax : label.setStyleSheet(“background-color: cyan”)
Argument : It takes string as argument.
Action performed: It changes the background color of the label.
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.
- PyQt5 – How to change size of the Label | label.resize method
- PyQt5 – Change background color of Label for anti hover state
- PyQt5 Label – Setting color to the Color Effect
- PyQt5 Label – Accessing color of the Color Effect
- PyQt5 – How to hide label | label.setHidden method
- PyQt5 Scrollable Label - Setting tool tip to the label part
- PyQt5 Scrollable Label - Getting tool tip text of the label part
- PyQt5 Scrollable Label – Setting tool tip duration to label part
- PyQt5 Scrollable Label – Getting tool tip duration of the label part
- PyQt5 Label – Checking if label is window type
- PyQt5 Label – Checking if label is widget type
- PyQt5 – How to change text of pre-existing label | setText method
- PyQt5 – How to change font and size of Label text ?
- PyQt5 - Changing background color of Label when hover
- PyQt5 Label - Setting color to shadow
- PyQt5 Label - Accessing shadow color
- PyQt5 Label – Setting strength to the Color Effect
- PyQt5 Label – Adding Color effect
- PyQt5 Label – Accessing the strength of the Color Effect
- PyQt5 Label – Getting Color effect object
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.