I have a number of properties (colours) in the root container. I want to change these properties based the properties of various components on the screen. (eg: is a switch open/close)
I know I could write an expression for each colour but a lot of the code would be duplicated. So I want to write a common module for each component type.
So the expression would look a bit like this:
if (app.SC5802.is_1_live(“component”) , color(1,2,3),
if (app.SC5802.is_1_live(“other component”) , color(2,3,4),
color(3,4,5))
My problem is how do I reference the component properties in the module is_1_live() ?
If you know the window and component name, you can get a reference to a component with the following script code:
from fpmi.gui import getWindow
window = getWindow("Window Name")
component = window.rootContainer.getComponent("Component Name")
Once you have a reference to the component, you can reference the component’s properties with statements like this:
property = component.property
If you need to access different windows and/or components, you might possibly be able to use global variables that you update in various ways.
To reference the module scripts as an expression, you’ll need to use the runScript() expression language function.
If the possible property names are limited, you can have an if, elif, else sequence of statements that checks the property string/variable. For example: