[PyQt5] indicator light display

[PyQt5] indicator light display

1. Background

When using Qt5 to write the interactive interface of industrial control software, it is often necessary to have an indicator light function on the interface.
For example, the light and shade below indicate the connection and disconnection of the serial port.
insert image description here
Our essence is to use the label text tag of Qt5 to achieve it, that is, to achieve it by setting the style sheet of the label.

Assume that the size of the label tag is 60px*60px, and the corresponding border-radius: 30px.
The style sheet of the bright light effect is as follows:

self.label.setStyleSheet("background-color: rgb(0, 234, 0);\n"
                                        "border-radius: 30px;\n"
                                        "

Guess you like

Origin blog.csdn.net/jn10010537/article/details/130917706