Style scripting in Ignition Perspective

I have notice in a post some scripting in this forum like this:

  • column.n.header.align : top
  • column.n.header.style.backgroundRepeat : no-repeat
  • column.n.header.style.backgroundImage : url("/system/images/Builtin/icons/48/logic_and.png")
  • column.n.header.style.height : 60px ← Set this to image + text height.
  • column.n.header.style.backgroundPosition : bottom

I wonder if is possible to add styles by script directly or should to do it by hand on the interface:

1 Like

Those aren't scripting. They are Perspective property settings.

You can edit and create (if they are valid) property settings by script. For example:
self.getSibling("Label_1").props.style.backgroundColor = "red"

1 Like

Where can I add the property settings?

You would have to add a button, write the script, run Preview in Designer, click the button, exit Preview, delete the button and save.

Or you could just create them normally for less work.

1 Like

I don´t know how to add those written settings into my props.

Then why did you mark post #2 as "Solution". I think you also marked the post where I gave those settings as solved as well?


Example: add column.n.header.style.backgroundRepeat : no-repeat to column 0:

Property creation

Go to the section where you want to create the property.

2 Likes

Yes, this I know how to do, what I don´t know is add the:

You can edit and create (if they are valid) property settings by script. For example:
self.getSibling("Label_1").props.style.backgroundColor = "red"

  • Create a view.
  • Add a label and a button.
  • On the button add
    backgroundColor : <anything>
  • On the button add an onActionPerformed event script.
  • Add the following code.
def runAction(self, event):
	if self.getSibling("Label").props.style.backgroundColor == "blue":
		self.getSibling("Label").props.style.backgroundColor = "grey"
	else:
		self.getSibling("Label").props.style.backgroundColor = "blue"
  • Switch on Preview mode and test.
2 Likes

Thanks a lot Transistor.