Getting Window Root Container Object from within a Template

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

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:

from javax.swing import SwingUtilities

but I am not that clued in about it.

Any help is appreciated.

Many thanks,

Max.

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

rootContainer = system.gui.getParentWindow(event).rootContainer
1 Like

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

image

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

image

1 Like

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

2 Likes

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

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

Should have mentioned this is in vision sorry!

1 Like

Works perfectly thanks!

1 Like