# How to iterate through all checkbox in a window through script

**URL:** <https://forum.inductiveautomation.com/t/how-to-iterate-through-all-checkbox-in-a-window-through-script/23866>\
**Category:** Ignition Early Access\
**Tags:** ignition80, scripting\
**Created:** [April 5, 2019, 6:05am UTC](https://forum.inductiveautomation.com/t/how-to-iterate-through-all-checkbox-in-a-window-through-script/23866 "2019-04-05T06:05:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tarun89engg](https://avatars.discourse-cdn.com/v4/letter/t/ecb155/32.png) [@tarun89engg](https://forum.inductiveautomation.com/u/tarun89engg)\
**Post date:** [April 5, 2019, 6:05am UTC](https://forum.inductiveautomation.com/t/how-to-iterate-through-all-checkbox-in-a-window-through-script/23866/1 "2019-04-05T06:05:51Z")

</div>

Hi all,

after referring to this below link  
[http://forum.inductiveautomation.com/t/iterating-through-components-on-a-screen-through-scripting/16335](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.

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

```

---

<div class="post-metadata">

**Author:** ![tarun89engg](https://avatars.discourse-cdn.com/v4/letter/t/ecb155/32.png) [@tarun89engg](https://forum.inductiveautomation.com/u/tarun89engg)\
**Post date:** [April 5, 2019, 8:10am UTC](https://forum.inductiveautomation.com/t/how-to-iterate-through-all-checkbox-in-a-window-through-script/23866/2 "2019-04-05T08:10:38Z")

</div>

I have tried the following way

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

---

<div class="post-metadata">

**Author:** ![silverbacknet](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/silverbacknet/32/7385_2.png) [@silverbacknet](https://forum.inductiveautomation.com/u/silverbacknet)\
**Post date:** [April 5, 2019, 10:06pm UTC](https://forum.inductiveautomation.com/t/how-to-iterate-through-all-checkbox-in-a-window-through-script/23866/3 "2019-04-05T22:06:19Z")

</div>

If you’re doing this as event processing in the same window, consider:

```auto
root = system.gui.getParentWindow(event).rootContainer

```

Since you’ll 90% of the time need recursive processing, the final would look more like:

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

```
