Disabling visibility on multiple containers

I’m trying to change the visibility of a number of containers in a window. Is it possible to use a for loop or do I need to replicate the following script x amount of times?

system.gui.getParentWindow(event).getComponentForPath(‘Root Container.Comms Container 1’).visible=0

Yes, you can use a loop. Here is an example:for i in range(5): system.gui.getParentWindow(event).getComponentForPath('Root Container.Comms Container %d' % (i+1)).visible = 0

Thanks! Got it to work but little confused on %d’ % syntax. Anywhere in the manual that explains?

It is used in Python string formatting. Take a look at this page in the user manual http://www.inductiveautomation.com/support/usermanuals/ignition/string_formatting.htm for more information.

Heres the exact same script with the second line broken down so that each line does one thing:

for i in range(5): path = 'Root Container.Comms Container %d' % (i+1) window = system.gui.getParentWindow(event) container = window.getComponentForPath(path) container.visible = 0