Hi all,
after referring to this below link
http://forum.inductiveautomation.com/t/iterating-through-components-on-a-screen-through-scripting/16335
I got to know that we can iterate trough all component from a root container.
what i would like to have it to iterate all checkbox and make them visible and invisible based on condition.
componentList = []
window = system.gui.getWindow('Auswertung/Recht')
container = window.getRootContainer()
for component in container.components:
# If the type of the Root Container and Component match,
# we're currently iterating over a container
if type(component) == type(container):
print "A container: %s" % component.name
# Otherwise, it's something else.
else:
print "Not a container: %s" % component.name
I have tried the following way
window = system.gui.getWindow('Mag Sch Auswertung/Mag_VWA_Re')
container = window.getRootContainer()
for component in container.components:
# If the type of the Root Container and Component match,
# we're currently iterating over a container
#print type(component)
if 'PMICheckBox' in str(type(component)):
print component.name
if anyone has a better suggestion pls let me know.
If you’re doing this as event processing in the same window, consider:
root = system.gui.getParentWindow(event).rootContainer
Since you’ll 90% of the time need recursive processing, the final would look more like:
root = system.gui.getParentWindow(event).rootContainer
def checkChecks(container):
for component in container:
if type(component) == type(container):
checkChecks(component)
elseif str(type(component)) == 'PMICheckBox':
print "Checkbox: " + container.name + '/' + component.name
# you could probably also use isinstance(component,com.inductiveautomation.factorypmi.application.components.PMICheckBox) somehow
checkChecks(root)
2 Likes