Implementing LED in PyQt Designer

时光总嘲笑我的痴心妄想 提交于 2019-12-01 00:40:36

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)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!