Changing Component Background with Script


I can’t get this to work and I don’t know what I’m doing wrong. (I get no errors, but does not change colors!)

‘’‘if “W1Flow” > “W1Setpoint” :
W1FPress = event.source
W1FPress.background = system.gui.color(255,0,0)’’’

W1Flow is a Tag value(Float) and W1Setpoint is a Tag value(Float)

W1FPress is a numeric label - I have this script in the property change event of W1FPress

All I trying to do is if the value of W1Flow becomes larger then W1Setpoint change the background color of W1FPress to red.


Just putting tag names in quotes doesn’t give you their value. You are just comparing those two strings lexically. You need to use to retrieve a tag value in scripting. Or bind those tags to custom properties of W1FPress and refer to them that way. In either case, a propertyChange script is wrong if it doesn’t include checking for the appropriate event.propertyName.

1 Like

Thanks, I understand - it is now working.