Script is not reading

def transform(self, value, quality, timestamp):
"""
Expects value to be a status string:
"Alert", "Running", "not_entry", "entry"

Returns a dict with 'text' and 'style' keys for Perspective binding.
"""

# Normalize input to avoid case/spacing issues
status_key = str(value).strip().lower()

if status_key == "alert":
    status = "Alert"
    bg, fg = "#FF0000", "#FFFFFF"   # red
elif status_key == "running":
    status = "Running"
    bg, fg = "#00A000", "#FFFFFF"   # green
elif status_key == "not_entry":
    status = "Product Take out Permitted"
    bg, fg = "#FFD54F", "#212121"   # yellow
elif status_key == "entry":
    status = "Product Entry Permitted"
    bg, fg = "#ADD8E6", "#073042"   # light blue
else:
    status = "Idle"
    bg, fg = "#BDBDBD", "#212121"   # neutral default

return {
    "text": status,
    "style": {
        "backgroundColor": bg,
        "color": fg,
        "fontWeight": "bold"
           }

can some one help on this

You can put all the info in the original post.. You can also edit posts.

Also you haven’t told us what the issue is. There’s no error in your screenshot..

Also also, you need to edit your post with the code and fix it up as you didn’t copy it into the code block properly. Take some time to get your info correct so we can help you.

there is no error in the code but in front end we are not able to see the colour changes in the label text

Show us the binding in the props.

1 Like

You have also not provided any context on what event should the colour change be triggered.

You can try to do a system.prespective.print("status_key "+str(status_key)) on you script to see if your binding is getting triggered at all.

You cropped out the context of the binding screenshot, ie. What is the binding being applied to? The output looks wrong. You seem to be outputting some styles and a text key which seems like the wrong part.

Anyway, show us what that binding is bound to.

Pretend that we don’t know your project, what’s in your head, and what you can see, because most of us can't :eyes:

3 Likes

Are you sure? When a script doesn't seem to run in Perspective, an exception is what I usually find. Double check the logs or add a temporary label to the project to send diagnostic data to. You could also wrap the whole script in a try/except block, and send the exception to the print console using system.perspective.print

I can see in your posted code block that you're missing a closing bracket on your return value:

return { 					# first open bracket
    "text": status,
    "style": {  			# second open bracket
        "backgroundColor": bg,
        "color": fg,
        "fontWeight": "bold"
           }				# first closing bracket
	#}						# missing second closing bracket