Get all components

I’m trying to iterate through some components on a window. Is there a way to grab components in an array? I’m familiar with getComponent - is there another function to grab all components?

You can call the getComponents() method on a container to get an array of all components in a container.

For example:

for comp in event.source.parent.getComponents():
	print comp.name

You could get the root container, get all the components in the root container and then check to see if any of those components are containers and if so get all the components in those containers etc. recursively. That would get you all the components (and nested components) within the root container of a window.

Will try that…thank you. Is getcomponents documented somewhere?

Yes, in the Java documentation: docs.oracle.com/javase/7/docs/ap … ents%28%29

Much of the Ignition GUI is built using Swing/AWT components.

Nick

I did some digging with Python. The getComponents method may be being overridden by another class that we don’t have documentation about.

I’d like to get a component and test if it’s a check box but I can’t seem to get it to work

win = system.gui.getWindow(“Trending/ToolScreens/Trend”)

template = win.getRootContainer().getComponent(“TrendView”).templates

comps = win.getRootContainer().getComponents()

tags = system.tag.browseTags(parentPath = “Trends/Tag History Pens”)

param = “TagPath”

x = type(comps[0])

for comp in comps:

print comp == x