# TypeError:getComponent():1st arg cant't be coerced to int

**URL:** <https://forum.inductiveautomation.com/t/typeerror-getcomponent-1st-arg-cantt-be-coerced-to-int/26958>\
**Category:** Ignition\
**Created:** [July 29, 2019, 3:57pm UTC](https://forum.inductiveautomation.com/t/typeerror-getcomponent-1st-arg-cantt-be-coerced-to-int/26958 "2019-07-29T15:57:58Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![ryanastiefes](https://avatars.discourse-cdn.com/v4/letter/r/47e85d/32.png) [@ryanastiefes](https://forum.inductiveautomation.com/u/ryanastiefes)\
**Post date:** [July 29, 2019, 3:57pm UTC](https://forum.inductiveautomation.com/t/typeerror-getcomponent-1st-arg-cantt-be-coerced-to-int/26958/1 "2019-07-29T15:57:58Z")

</div>

So I think I have the hang of this scripting stuff, but I have ran into a problem I’ve been trying to figure out for the past two days.  
Im using Kymera Map Module  
Ignition 8.0.1  
I want when mouse enters the point to popup a label with values. I can get them to print to the console but when I try to  
send the text to a label using

def onPointEntered(self, event, point):  
event.source.parent.getComponent(‘Label 8’).text = “Hello Hello”

I get the following:

File “”, line 12, in onPointEntered  
TypeError: getComponent(): 1st arg can’t be coerced to int

Any thoughts?

---

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [July 29, 2019, 4:21pm UTC](https://forum.inductiveautomation.com/t/typeerror-getcomponent-1st-arg-cantt-be-coerced-to-int/26958/2 "2019-07-29T16:21:14Z")

</div>

That’s not a Numeric Label is it? This is for the MouseEntered property change?

---

<div class="post-metadata">

**Author:** ![ryanastiefes](https://avatars.discourse-cdn.com/v4/letter/r/47e85d/32.png) [@ryanastiefes](https://forum.inductiveautomation.com/u/ryanastiefes)\
**Post date:** [July 29, 2019, 4:23pm UTC](https://forum.inductiveautomation.com/t/typeerror-getcomponent-1st-arg-cantt-be-coerced-to-int/26958/3 "2019-07-29T16:23:53Z")

</div>

No, it’s just your typical Display Label.  
onPointEntered() is from the kymera module.  
I figured it was a random enough error that anyone with scripting knowledge could elaborate.

---

<div class="post-metadata">

**Author:** ![ryanastiefes](https://avatars.discourse-cdn.com/v4/letter/r/47e85d/32.png) [@ryanastiefes](https://forum.inductiveautomation.com/u/ryanastiefes)\
**Post date:** [July 29, 2019, 4:32pm UTC](https://forum.inductiveautomation.com/t/typeerror-getcomponent-1st-arg-cantt-be-coerced-to-int/26958/4 "2019-07-29T16:32:19Z")

</div>

I got in touch with Kymera here is what they advised:

We would suggest you to use self(first argument of onPointEntered()) instead of event.source for what you are doing, So your code will look like  
self.parent.getComponent(‘Label 8’).text = “Hello Hello”

Here is little explanation of why you are getting that error. In onPointEntered() method, event.source.parent gives you the pointLayer and not the Root Container of the window. The getComponent() for pointLayer takes integer argument which is the index of the point on Map Panel.  
For example: If you still want to use “event” argument for what you are doing, you can achieve that with below code: event.source.parent.getComponent(0).parent.parent.parent.getComponent(‘Label’).text = “Hello Hello”  
where getComponent(0) gives you the first point on the Map.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [July 29, 2019, 4:33pm UTC](https://forum.inductiveautomation.com/t/typeerror-getcomponent-1st-arg-cantt-be-coerced-to-int/26958/5 "2019-07-29T16:33:55Z")

</div>

I can tell you where it’s coming from, but not really what the fix is - it looks like Kymera might need to do something differently. `getComponent()` is actually a base method on Java’s [`Container`](https://docs.oracle.com/en/java/javase/11/docs/api/java.desktop/java/awt/Container.html#getComponent(int)) class - but it only accepts integers, as component index paths. In Ignition, we wrap all of our classes when we expose them to scripting, and we added an “overload” to `getComponent` that allows you to specify a single component’s name - but that breaks down if you ever get outside the boundaries of what we “expect” you to reach in scripting. For example, if you wanted to deeply customize, say, an alarm status table…you would need component _index_ paths to reach a button to change its font size.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [July 29, 2019, 4:40pm UTC](https://forum.inductiveautomation.com/t/typeerror-getcomponent-1st-arg-cantt-be-coerced-to-int/26958/6 "2019-07-29T16:40:17Z")

</div>

> [@paul-griffith](#):
>
> In Ignition, we wrap all of our classes when we expose them to scripting, and we added an “overload” to `getComponent` that allows you to specify a single component’s name - but that breaks down if you ever get outside the boundaries of what we “expect” you to reach in scripting.

If you want a detailed explanation, this thread might help, particularly the pitfalls and their work-arounds:

> [@Transaction groups triggered expression item updating when trigger is false](http://forum.inductiveautomation.com/t/transaction-groups-triggered-expression-item-updating-when-trigger-is-false/17196/14):
>
> Ok, so I’ve been down the rabbit hole and found Ignition’s (undocumented) PyComponentWrapper. I haven’t deciphered it enough to be sure, but it seems to be invoked only for particular situations, based on the string constants in the class file (like “getComponent” and “getComponents”). To play with this, I constructed a conversion adapter like so: public class PyComponentAdapter implements PyObjectAdapter { public PyComponentAdapter() {} @Override public boolean canAdapt(Object jObj) { …

Note that I wouldn't expect Kymera's PointLayer to take string lookups, so the wrapper is moot.

---

<div class="post-metadata">

**Author:** ![Ryan\_Shaw](https://avatars.discourse-cdn.com/v4/letter/r/dbc845/32.png) [@Ryan\_Shaw](https://forum.inductiveautomation.com/u/Ryan_Shaw)\
**Post date:** [December 3, 2022, 10:29pm UTC](https://forum.inductiveautomation.com/t/typeerror-getcomponent-1st-arg-cantt-be-coerced-to-int/26958/7 "2022-12-03T22:29:07Z")

</div>

For those of you coming to this error from an extension function, you might have copy/pasted from somewhere and forgotten to change "event.source" to "self".
