# Get all components

**URL:** <https://forum.inductiveautomation.com/t/get-all-components/7634>\
**Category:** Ignition\
**Tags:** vision\
**Created:** [November 27, 2013, 6:53pm UTC](https://forum.inductiveautomation.com/t/get-all-components/7634 "2013-11-27T18:53:09Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![kwj](https://avatars.discourse-cdn.com/v4/letter/k/838e76/32.png) [@kwj](https://forum.inductiveautomation.com/u/kwj)\
**Post date:** [November 27, 2013, 6:53pm UTC](https://forum.inductiveautomation.com/t/get-all-components/7634/1 "2013-11-27T18:53:09Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![nmudge](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nmudge/32/3394_2.png) [@nmudge](https://forum.inductiveautomation.com/u/nmudge)\
**Post date:** [November 27, 2013, 7:02pm UTC](https://forum.inductiveautomation.com/t/get-all-components/7634/2 "2013-11-27T19:02:22Z")

</div>

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

For example:

```auto
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.

---

<div class="post-metadata">

**Author:** ![kwj](https://avatars.discourse-cdn.com/v4/letter/k/838e76/32.png) [@kwj](https://forum.inductiveautomation.com/u/kwj)\
**Post date:** [November 27, 2013, 7:14pm UTC](https://forum.inductiveautomation.com/t/get-all-components/7634/3 "2013-11-27T19:14:17Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![nmudge](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nmudge/32/3394_2.png) [@nmudge](https://forum.inductiveautomation.com/u/nmudge)\
**Post date:** [November 27, 2013, 7:27pm UTC](https://forum.inductiveautomation.com/t/get-all-components/7634/4 "2013-11-27T19:27:40Z")

</div>

Yes, in the Java documentation: [docs.oracle.com/javase/7/docs/ap … ents%28%29](http://docs.oracle.com/javase/7/docs/api/java/awt/Container.html#getComponents%28%29)

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

Nick

---

<div class="post-metadata">

**Author:** ![nmudge](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nmudge/32/3394_2.png) [@nmudge](https://forum.inductiveautomation.com/u/nmudge)\
**Post date:** [November 27, 2013, 9:40pm UTC](https://forum.inductiveautomation.com/t/get-all-components/7634/5 "2013-11-27T21:40:47Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![tbraun](https://avatars.discourse-cdn.com/v4/letter/t/ea5d25/32.png) [@tbraun](https://forum.inductiveautomation.com/u/tbraun)\
**Post date:** [October 2, 2018, 9:29pm UTC](https://forum.inductiveautomation.com/t/get-all-components/7634/6 "2018-10-02T21:29:57Z")

</div>

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
```

---

<div class="post-metadata">

**Author:** ![kaushik.shah](https://avatars.discourse-cdn.com/v4/letter/k/34f0e0/32.png) [@kaushik.shah](https://forum.inductiveautomation.com/u/kaushik.shah)\
**Post date:** [May 1, 2024, 4:27pm UTC](https://forum.inductiveautomation.com/t/get-all-components/7634/7 "2024-05-01T16:27:00Z")

</div>

Is there a way to get type of component? I am looking to find all the power tables I have within a window.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [May 1, 2024, 4:28pm UTC](https://forum.inductiveautomation.com/t/get-all-components/7634/8 "2024-05-01T16:28:26Z")

</div>

Python's native `type()` function will give you the class of a java object, from which you can see what kind of component it is.

---

<div class="post-metadata">

**Author:** ![kaushik.shah](https://avatars.discourse-cdn.com/v4/letter/k/34f0e0/32.png) [@kaushik.shah](https://forum.inductiveautomation.com/u/kaushik.shah)\
**Post date:** [May 1, 2024, 5:39pm UTC](https://forum.inductiveautomation.com/t/get-all-components/7634/9 "2024-05-01T17:39:35Z")

</div>

didn't think of that actually, thanks so much

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [May 2, 2024, 1:29am UTC](https://forum.inductiveautomation.com/t/get-all-components/7634/10 "2024-05-02T01:29:47Z")

</div>

> [@kaushik.shah](#):
>
> find all the power tables I have within a window

```python
# Written for the action performed event handler of a button in the root container of the window.
# Iterate through all of the components
for component in event.source.parent.components:

	# Check to see if the component is a power table
	if 'VisionAdvancedTable' in component. __class__. __name__ :
		
		# If so, print the name of the component to the diagnostic console
		print component.name

```

If the power tables are nested in containers, then move this to a recursive function that gets called again any time a `BasicContainer` class is encountered during an iteration.
