Getcomponent() problem

I have the following script:

def updateInputs(window): for comp in window.getRootContainer().getComponents(): if comp.name.startswith('Input') : comp.getComponent('textfield').floatValue = comp.In_Value

On the window in question, I have a number of instances of a template that contain a numeric text field (“textfield”). I am using it to change a tag through some scripting (its not just bound to a tag). So when the window opens, the values are all 0. I want them to open at the value of the tag (hence the script, which is called when the window opens).

When the script is called, I get TypeError: getComponent(): 1st arg can’t be coerced to int. I have also tried .intValue instead of .floatValue with the same result. In_Value is a custom property (float) of the template containing “textfield”.

Any ideas?

[quote=“kwj”]I have the following script:

def updateInputs(window): for comp in window.getRootContainer().getComponents(): if comp.name.startswith('Input') : comp.getComponent('textfield').floatValue = comp.In_Value

On the window in question, I have a number of instances of a template that contain a numeric text field (“textfield”). I am using it to change a tag through some scripting (its not just bound to a tag). So when the window opens, the values are all 0. I want them to open at the value of the tag (hence the script, which is called when the window opens).

When the script is called, I get TypeError: getComponent(): 1st arg can’t be coerced to int. I have also tried .intValue instead of .floatValue with the same result. In_Value is a custom property (float) of the template containing “textfield”.

Any ideas?[/quote]

You already have a reference to the component, all you have to do is:

[comp]comp.floatValue = comp.In_Value[/code]

Edit: Nevermind, on a 2nd read I see that you are looking for a child component of the template. You might have to use comp.getParent().getComponent(“textfield”) but I can’t test it right now.

“NoneType object has no attribute floatValue”

Crap. Thanks for the suggestion though.

Is comp.In_Value bound to the tag value? If so I would think that you could update the value of the numeric text field from within the template when the value of In_Value changes.