I would like to set several custom properties when a Window opens or is navigated back to.
Currently I have a script on the Window's internalFrameActivated that makes a call to a custom function on a Container.
def setValues(self):
def handleContainer(container):
for comp in container.getComponents():
if comp.__class__.__name__ == 'PMILabel':
processLabels(comp)
def processLabels(label):
try:
setattr(label, 'myVal', 'Bonjour')
print 'processLabels call'
except AttributeError:
print lalel.setPropertyValue('myVal', 'Bonjour')
handleContainer(self)
I have four labels, each with a custom property of myVal. The custom function executes, and prints processLabels, but the label's texts remain unchanged.
The previous script used this instead of setattr: label.myVal = 'Bojnour'
Turns out, it helps to bind the text property to the correct custom property!
EDIT: Ok, that worked on the test dummy, but it's not working at all in the actual project.
Same basic setup, except that I get an error stating that the custom function does not exist, specifically object has no attribute setRepeaterMinEnable
Long-standing gap in the application of Ignition's PyComponentWrapper everywhere it might be needed. When jython applies default wrapping to a VisionComponent, it doesn't end up with the attributes for custom properties and custom methods. Details here:
TL/DR: Install my Integration Toolkit to get fully automatic wrapping. If you cannot do that, use the PyComponentWrapper manually.