Template to resize component

I quite liked the idea of resizing a component to show more detail, as shown in the Ignition Gold Test.

I tried to make my own template which could be passed a component name of a component on the main window the template is placed. On click of the template would then use system.gui.transform to resize the component to a new width/height, and then back to its original width/height on second click.

Currently i am getting no errors in the console, but instead of resizing the component i want, it is resizing my template.
Is it not possible to get a reference to a component on a main window, from a template script?

Here is the code i have written on the mousePressed event of my template:

"""	Resize a component to specified new dimensions. 
	Reverts to original dimensions on second click
"""

window = system.gui.getParentWindow(event)
print window
component = window.rootContainer.getComponent(event.source.parent.componentName)
print component.name

def func():
		if component.width == event.source.parent.newWidth:
			event.source.isExpanded = 1
def func2():
		if component.width == event.source.parent.origWidth:
			event.source.isExpanded = 0
if not event.source.isExpanded:
	system.gui.transform(component,newHeight=event.source.parent.newHeight,duration=250,callback=lambda: system.gui.transform(event.source.parent.parent,newWidth=event.source.parent.newWidth,duration=250, callback=lambda: func()))
else:
	system.gui.transform(component, newHeight=event.source.parent.origHeight,duration=250, callback=lambda: system.gui.transform(event.source.parent.parent,newWidth=event.source.parent.origWidth,duration=250, callback=lambda: func2()))

The print statements are returning what i expect, so i’m not sure why the component isn’t being modified.

Fixed:
Didn’t see the error on the second “system.gui.transform” function.

event.source.parent.parent

Needed to be replaced with:

component