Is it possible to access window components from the project library scripts?

  1. I have a window called 'operator_controller' and im trying to run a function in one of my charts (image 1)

  2. To call that function im using the code in the second image. This is code is located in the Project Library scripts

But i get this error:

Error executing script.
Traceback (most recent call last):
File "tagevent:alarmActive", line 3, in alarmActive
File "module:GlobalScripts", line 188, in alarmact
AttributeError: 'com.inductiveautomation.ignition.common.script.Imm' object has no attribute 'gui'

So its basically saying system.gui does not work in the project library scripts? is there another way to do this?

Thanks

But what is calling the project library function in (2)? i.e. what is calling "alarmActive"? Looks like this is coming from a tag change event? in which case this is running in the gateway scope which doesn't know about Vision, hence no gui functions will work

Expanding on this:

They can, under some circumstances. It isn't whether you are calling from a project script, but what ultimately called the project script. Project scripts are present in gateway scope (by project), designer scope, Vision client scope, and Perspective scope (a variant of gateway scope). But the contents of the system library varies by calling scope.

Interacting with other execution scopes involves messaging. Project scripts are not a scope in and of themselves.

The system.gui.* and system.nav.* functions exist in Vision Client scope, and Designer scope when Vision is installed.

1 Like

yes ure right. a tag change event is calling the project library function.
how do you propose i do this then?

You need to monitor that alarm tag (.../Alarm tags/Alarm Active) in the clients e.g. in a Vision Client Tag, and open your popup from there, assuming I'm interpreting what you're trying to do correctly. I.e. open a popup when an alarm activates (you haven't given any detail about what you're actually trying to achieve)

Not necessary. A Vision Client Tag Change Event would suffice.

You don't. Or more precisely, not from gateway scope.

You write your script to run in some client scope, Vision or Perspective. See this related discussion:

Note especially how your UI should pull the data it needs from global resources, including tags, not have those resources try to push to the UI.

im trying to open a popup when an alarm is active. the system.gui functions dont work from a tag change event either

Ah yes, I forgot about those... Perspective is replacing my Vision memory!

Put this code in a client-scoped tag change event (not on the tag, but in the Vision section of the designer tree).