Images

Hi,
How do I enter a color as property(java.awt.color) How does this look like?
#FF0F02 or 245,33,43 or …?

grtz,
Tijs

it looks like #,#,#

Traceback (innermost last):
File “event:mousePressed”, line 7, in ?
[color=#FF0040]TypeError: can’t convert ‘0,10,10’ to java.awt.Color[/color]

at org.python.core.Py.TypeError(Py.java)
at org.python.core.Py.tojava(Py.java)
at org.python.core.PyBeanProperty._doset(PyBeanProperty.java)
at org.python.core.PyInstance.__setattr__(PyInstance.java)
at com.inductiveautomation.factorypmi.application.script.PyComponentWrapper.__setattr__(PyComponentWrapper.java:62)
at org.python.pycode._pyx16.f$0(<event:mousePressed>:7)
at org.python.pycode._pyx16.call_function(<event:mousePressed>)
at org.python.core.PyTableCode.call(PyTableCode.java)
at org.python.core.PyCode.call(PyCode.java)
at org.python.core.Py.runCode(Py.java)
at com.inductiveautomation.ignition.common.script.ScriptManager.runCode(ScriptManager.java:367)
at com.inductiveautomation.factorypmi.application.binding.action.ActionAdapter.runActions(ActionAdapter.java:138)
at com.inductiveautomation.factorypmi.application.binding.action.ActionAdapter.invoke(ActionAdapter.java:280)
at com.inductiveautomation.factorypmi.application.binding.action.RelayInvocationHandler.invoke(RelayInvocationHandler.java:55)
at $Proxy0.mousePressed(Unknown Source)
at java.awt.AWTEventMulticaster.mousePressed(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)

Have a look at Scripting/Python/API Reference/system.gui.color in the help.

You would do something likeevent.source.parent.getComponent('Rectangle').background = system.gui.color(0,10,10)Note that now you can also doevent.source.parent.getComponent('Rectangle').background = system.gui.color("#FF0000")or even event.source.parent.getComponent('Rectangle').background = system.gui.color("red")
As an aside, I also found that even event.source.parent.getComponent('Rectangle').background = 0,10,10(no quotes) works!

I’m unsure exactly what you’re trying to do. If you’re wanting to bind a color to a property you can use one of the following expressions:

  1. toColor(“nRed, nGreen, nBlue, nAlpha”)

where nRed, nGreen, nBlue, and nAlpha are integer values from 0 to 255.

  1. toColor(“ColorName”)

where ColorName is a named color such as “AliceBlue”, “Aqua”, “Biege”, etc.

  1. color(nRed, nGreen, nBlue, nAlpha)
    where, again, nRed, nGreen, nBlue, and nAlpha are integer values from 0 to 255

See the User Manual, Technical Reference>>Expression Language>>Type Casting Functions>>toColor, Technical Reference>>Expression Language>>Type Casting Functions>>Named Color Table, or Technical Reference>>Expression Language>>Color Functions>>color for more details.

Al pretty much covered the subject with regard to Jython scripting.