taurus-org / taurus

Moved to https://gitlab.com/taurus-org/taurus
http://taurus-scada.org
43 stars 46 forks source link

Set color to TaurusCommandButton #1070

Closed hayg25 closed 4 years ago

hayg25 commented 4 years ago

Dear All, I would like to update the TaurusCommandButton accordingly to the value of a Ds attribute (False or True), and which does 2 thinks : 1) Switch ON/OFF by clicking on it (and update the color at the same time) 2) shows by the color (and text) the status (updates with the value of the attribute)

Thanks for the feedback

cpascual commented 4 years ago

I would suggest to create your own button class that inherits from TaurusCommandButton and possibly call setStyleSheet() (see QWidget's stylesheets API) to change the button colors for your own widget, not for the TaurusCommandButton

cpascual commented 4 years ago

... and all the specific logic that you want can be implemented by reimplementing the onClicked method of the TaurusCommandButton

hayg25 commented 4 years ago

dear @cpascual, thx for the solution. Indeed, that's "elegant" solution. In my mind it was needed to prevent to make it as with 2 graphical objects : one led + one button.