Value for foreground property when assigning to label or text through code


I wish the Ignition documentation is clearer about what value to use for the scripting function like ".foreground"

	> event.source.parent.getComponent('notLbl').foreground = "green"

I tried using hex > "#fff", rgb > "255,255,2555", and the actual color name > "white" but it still gives me this error.

Traceback (most recent call last):
File "event:actionPerformed", line 20, in
TypeError: can't convert 'white' to java.awt.Color

Maybe this is so simple, but just frustrating that I cant find it anywhere how to do this.

thanks for any help.

Hi, try using this function.

The error tells you that foreground is expecting to be set with a java.awt.Color object. As Kleppe85 stated, you can get this color with system.gui.color(). Another option is to import the Color class and use it directly.

from java.awt import Color = Color(r,b,g,a) = Color.BLACK

Generally speaking, use system.gui.color if you dont understand how imports work and the impact they could have on your code.


this works! Thanks a lot!