# Getting Window Root Container Object from within a Template

**URL:** <https://forum.inductiveautomation.com/t/getting-window-root-container-object-from-within-a-template/91811>\
**Category:** Ignition\
**Tags:** vision, scripting\
**Created:** [June 13, 2024, 10:14am UTC](https://forum.inductiveautomation.com/t/getting-window-root-container-object-from-within-a-template/91811 "2024-06-13T10:14:05Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![MG3](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mg3/32/84125_2.png) [@MG3](https://forum.inductiveautomation.com/u/MG3)\
**Post date:** [June 13, 2024, 10:14am UTC](https://forum.inductiveautomation.com/t/getting-window-root-container-object-from-within-a-template/91811/1 "2024-06-13T10:14:05Z")

</div>

Hi all,

From a Template I am looking to have a Script that will need to access a component on the Root Container. Is there any simple way to get the Root Container of the Parent Window to the Template?

I am unsure if

```python
event.source.parent.parent.parent....

```

would work in this situation, I did give it a little go and couldn't figure out how many I'd need. I have heard things about the:

```python
from javax.swing import SwingUtilities

```

but I am not that clued in about it.

Any help is appreciated.

Many thanks,

Max.

---

<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:** [June 13, 2024, 10:21am UTC](https://forum.inductiveautomation.com/t/getting-window-root-container-object-from-within-a-template/91811/2 "2024-06-13T10:21:00Z")

</div>

You can use this from any event handler in the template:

```python
rootContainer = system.gui.getParentWindow(event).rootContainer

```

---

<div class="post-metadata">

**Author:** ![Alejandro\_Alaco](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/alejandro_alaco/32/59849_2.png) [@Alejandro\_Alaco](https://forum.inductiveautomation.com/u/Alejandro_Alaco)\
**Post date:** [June 13, 2024, 10:30am UTC](https://forum.inductiveautomation.com/t/getting-window-root-container-object-from-within-a-template/91811/3 "2024-06-13T10:30:06Z")

</div>

The way I use to now the route is go to the property binding

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/1/d10f02ee1cb967182364fda6301116ce6f73bca4.png)

and then navigate through the properties and click the one I need so I kow the route and can use it elsewhere

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/e/3ea28414acb80f0d1fd0c898c4afeeecb1600685.png)

---

<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:** [June 13, 2024, 10:33am UTC](https://forum.inductiveautomation.com/t/getting-window-root-container-object-from-within-a-template/91811/4 "2024-06-13T10:33:19Z")

</div>

> [@Alejandro\_Alaco](#):
>
> navigate through the properties

If the idea is drag, drop, done, this approach won't work generically from within a Vision template script.

---

<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:** [June 13, 2024, 10:44am UTC](https://forum.inductiveautomation.com/t/getting-window-root-container-object-from-within-a-template/91811/5 "2024-06-13T10:44:36Z")

</div>

It's also possible to use `getComponentForPath` to get specific components by name  
**Example:**

```python
# Gets a component named textfield that is nested in a root container named "Root Container"
textfield = system.gui.getParentWindow(event).getComponentForPath('Root Container.textfield')

```

---

<div class="post-metadata">

**Author:** ![MG3](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mg3/32/84125_2.png) [@MG3](https://forum.inductiveautomation.com/u/MG3)\
**Post date:** [June 13, 2024, 11:01am UTC](https://forum.inductiveautomation.com/t/getting-window-root-container-object-from-within-a-template/91811/6 "2024-06-13T11:01:58Z")

</div>

Should have mentioned this is in vision sorry!

---

<div class="post-metadata">

**Author:** ![MG3](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mg3/32/84125_2.png) [@MG3](https://forum.inductiveautomation.com/u/MG3)\
**Post date:** [June 13, 2024, 12:11pm UTC](https://forum.inductiveautomation.com/t/getting-window-root-container-object-from-within-a-template/91811/8 "2024-06-13T12:11:22Z")

</div>

Works perfectly thanks!
