3
votes

I am new to PyQt and QtDesigner. I want to add an LED in my GUI. can anyone kindly suggest How can I add LED in my GUI and change its color in my application?

1
Hi Avanish, welcome to SO. An appropriate tutorial might be of help. - J. Chomel
Hi @Chomel, I have seen some tutorials from [link] (zetcode.com/gui/pyqt4) and found some py qt apps from [link] (linux-apps.com/p/1132197). However could not add this app on Qt Designer. - Avanish Ojha

1 Answers

4
votes

I have implemented a green/red LED indicator in my application "Grid Control", please have a look at the code on Github it may give you some ideas.

I have defined two LED icons in my resource file as follows:

ICON_RED_LED = ":/icons/led-red-on.png"
ICON_GREEN_LED = ":/icons/green-led-on.png"

The icon can activated like this:

self.ui.labelStatusFan1.setPixmap(QtGui.QPixmap(ICON_RED_LED))

Also, by using signals, the icon can be activated based on some condition:

self.pixmap_signal_fan1.emit(ICON_RED_LED if fans_rpm[0] == 0 or fans_voltage[0] == 0 else ICON_GREEN_LED)