PyQt5 – How to create Label with multicolor border ?

When we create border of a label, it is of same color i.e all the edges are of same color. In this article, we will see how to create multi-colored borders i.e all the edges are of different color.
In order to do this, we will use setStyleSheet() method.
Syntax :
label.setStyleSheet("border :5px solid ;" "border-top-color : red; " "border-left-color :pink;" "border-right-color :yellow;" "border-bottom-color : green")Argument : It takes string as argument.
Action performed : It changes the color of each edge.
Code :
| # importing the required libraries  fromPyQt5.QtCore import*fromPyQt5.QtGui import*fromPyQt5.QtWidgets import*importsys   classWindow(QMainWindow):     def__init__(self):         super().__init__()           # set the title         self.setWindowTitle("Python")          # setting  the geometry of window         self.setGeometry(60, 60, 600, 400)           # creating a label widget         self.label_1 =QLabel(self)          # moving position         self.label_1.move(100, 100)          # setting up the border         self.label_1.setStyleSheet("border :5px solid blue;")          # setting label text         self.label_1.setText("Single colored")          # resizing label         self.label_1.resize(100, 50)         # creating a label widget         self.label_2 =QLabel(self)          # moving position         self.label_2.move(160, 170)          # setting up the border and changing color of each edge         self.label_2.setStyleSheet("border :5px solid ;"                                   "border-top-color : red; "                                   "border-left-color :pink;"                                   "border-right-color :yellow;"                                   "border-bottom-color : green")           # setting label text         self.label_2.setText("Multi colored")         self.label_2.resize(100, 50)            # show all the widgets         self.show()   # create pyqt5 app App =QApplication(sys.argv)  # create the instance of our Window window =Window() # start the app sys.exit(App.exec())  | 
Output :
 
				 
					



