Understanding a Template's structure: event.source.parent.parent

This inquiry is with regards to template structures in Vision.

Screenshot 2024-06-30 140046

I have the following actionPerformed event script configured on a button within a template:
print event.source.parent.name
print event.source.parent.parent.name
print event.source.parent.parent.parent.name

I have placed the template in a Main Window. When I click on the button, I see the following output on the console:
script_test
script_test
Root Container

Note that "script_test" is the name of the template.

I do not have a template nested within a template. Why do both parent and parent.parent reference the template? Do templates have some sort of master structure and substructure?

This is for my own understanding. I appreciate all explanations.

Yes. And both template canvas and template repeater have three layers instead of two, to allow for scrolling.

1 Like

When you drag and drop a template into a window, the template gets placed into a special container called a template holder. The template holder gets the same name as the Vision template.

print event.source.parent.__class__.__name__
print event.source.parent.parent.__class__.__name__
print event.source.parent.parent.parent.__class__.__name__

The output will be something like this:
Vision Template
Template Holder
Root Container

1 Like