"system" functions not available from client

I have a template with a custom script, then several instances of that template in a popup window. If I test the popup window in Preview mode from the designer everything work perfectly. As soon as I try to run the script from the client all the system.* functions throw an error, such as system.gui.messageBox and system.tag.read.

When running from the client I get an error of Object has no attribute 'gui' or 'tag' depending on which system function I call first (I've switched the execution order several times).

Is there a problem accessing system functions from the client? I'm really at a loss.

As I'm writing this the following topic appeared as a suggestion and states this was a bug in the past:

Is this still a bug?

Thanks,

Lane

So, Custom Script on a Vision Template, you have an instance of the Vision Template on a Vision Window, and attempting to triggering the custom script from the window causes the error? If so, then I’m unable to replicate (using 8.0.5 nightly at the moment). What version of Ignition are you using?

Also, it might be helpful to show us the script you’re using, the full error, screenshots, etc.

Paul,

Thank you for your fast reply. After a good nights sleep I decided to see if I could duplicate the problem with a new template and a new popup window.

  1. Created a template with a label and button, put a custom method at the highest level in the template (window level??):

def TestCustomMethod(self):
system.gui.messageBox(‘This is the test method’)

  1. Created a popup window
    2a. Placed an instance of the template in the window
    2b. Put a custom property in the Root Container called page_number type integer
    2c. Put a spinner in and linked it to the page_number property to change the integer value
    2d. Created a property change script in the Root Container to call the custom method in the template when page_number changes:

if event.propertyName == ‘page_number’:
component_string = ‘TestTemplate’
event.source.getComponent(component_string).TestCustomMethod()

  1. At this point I pop the window up from my main screen in my Vision Client and everything works as expected (much to my surprise), no errors.

  2. I also need to run the method when the window opens, so I add a nearly identical script to the visionWindowOpened event on the popup window:

component_string = ‘TestTemplate’
event.source.rootContainer.getComponent(component_string).TestCustomMethod()

The addition of the script to the visionWindowOpened event throws the error on both the window open script AND the property change script. The script that worked before now does not work.

I am using Ignition 8.0.3.

Text of the error message, the template and the popup window is attached.

Custom_Event_Test.zip (8.4 KB)

gui_error.txt (2.5 KB)

BTW - Indentations are correct in the script, the tabs get lost when typing here.

Thanks,

Lane

Thank you for the backup! It helped immensely!

I was able to replicate the problem. It’s interesting that the initial failure causes later executions to fail. That certainly seems like something we want to address.

In the mean time, this appears to be a race condition of sorts. Instead of calling the custom method initially from visionWindowOpened, call it from internalFrameOpened.

The there’s a brief discussion on this page about the order those events (as well as the event description in the script window), but I’m assuming the part about “…before any bindings on the window are evaluated” ties to this case for some reason.

I’ll make a ticket here, but mind trying to call your script from the internalFrameOpened event instead?

A simple cut and paste to internalFrameOpened from visionWindowOpened fixed the issue. I'll have to take a closer look at the order of events in the near future.

Thank you very much for your help!

Lane

Glad to hear it worked! In your defense, the event order is far from clear based on the description, which is something I’m trying to get changed.