Component Scripting - get only a certain type of component from getComponents()

I’d like to get a list of all the check boxes objects within a root container. Is there a way to test for component type?

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
from com.inductiveautomation.factorypmi.application.components import PMICheckBox
for comp in rootContainer.getComponents():
    if isinstance(comp, PMICheckBox):
        pass  # do something

Note that technically, you’ll want to call getComponents() recursively, and you also need to separate Vision “container-like” components from raw JComponents (all of which have a getComponents method).

Class names for the various default components are available here.


Thank you,

I did just get this to work:

for comp in comps:

if 'PMICheckBox' in str(x.getClass()):