# Event.source or system.gui strange error

**URL:** <https://forum.inductiveautomation.com/t/event-source-or-system-gui-strange-error/61783>\
**Category:** Ignition\
**Tags:** vision\
**Created:** [July 12, 2022, 9:28am UTC](https://forum.inductiveautomation.com/t/event-source-or-system-gui-strange-error/61783 "2022-07-12T09:28:04Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kelltek](https://avatars.discourse-cdn.com/v4/letter/k/b4bc9f/32.png) [@Kelltek](https://forum.inductiveautomation.com/u/Kelltek)\
**Post date:** [July 12, 2022, 9:28am UTC](https://forum.inductiveautomation.com/t/event-source-or-system-gui-strange-error/61783/1 "2022-07-12T09:28:04Z")

</div>

I am having a really hard time figuring out what I am doing wrong with my event handlers.

Traceback (most recent call last):  
File “event:mouseDragged”, line 7, in   
AttributeError: ‘com.inductiveautomation.vision.api.client.componen’ object has no attribute ‘mX’

Ignition v8.1.18 (b2022061518)  
Java: Azul Systems, Inc. 11.0.15

I am unable to even pull or target a custom property on a component using the event handlers on almost any component. Am I missing something?

something as simple as

window = system.gui.getParentWindow(event)

on a released event on a title bar throws this. What am I doing wrong?

---

<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 12, 2022, 11:23am UTC](https://forum.inductiveautomation.com/t/event-source-or-system-gui-strange-error/61783/2 "2022-07-12T11:23:45Z")

</div>

Install my (free) Simulation Aids module from the Showcase. Then these will magically work. For an in-depth explication of the situation with PyComponentWrapper, see this topic:

> [@Transaction groups triggered expression item updating when trigger is false](https://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) { …

---

<div class="post-metadata">

**Author:** ![Kelltek](https://avatars.discourse-cdn.com/v4/letter/k/b4bc9f/32.png) [@Kelltek](https://forum.inductiveautomation.com/u/Kelltek)\
**Post date:** [July 12, 2022, 7:51pm UTC](https://forum.inductiveautomation.com/t/event-source-or-system-gui-strange-error/61783/3 "2022-07-12T19:51:44Z")

</div>

Is this my issue?

Is this a bug or a permissions issue when utilizing portions of ignitions API?

A large portion of the snippets on the forum don’t work. Scripting outside of the script builder code from the designers UI is almost unusable. Built ins like event.source.parent are not even able to be parsed correctly.

---

<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 12, 2022, 8:55pm UTC](https://forum.inductiveautomation.com/t/event-source-or-system-gui-strange-error/61783/4 "2022-07-12T20:55:10Z")

</div>

> [@Kelltek](#):
>
> Is this my issue?

Please show more code.

If it is your issue, then it isn't so much a bug as a missing feature.

---

<div class="post-metadata">

**Author:** ![Kelltek](https://avatars.discourse-cdn.com/v4/letter/k/b4bc9f/32.png) [@Kelltek](https://forum.inductiveautomation.com/u/Kelltek)\
**Post date:** [July 14, 2022, 7:32am UTC](https://forum.inductiveautomation.com/t/event-source-or-system-gui-strange-error/61783/5 "2022-07-14T07:32:41Z")

</div>

is there a timeline when this “feature” will be added. seems like a massive limitation.  
I can run most of the system calls if I include system in my custom methods but I can’t use .getParentWindow.  
Is there a way to pass a valid event object into a custom method that qualifies.  
I basically just want to calla custom method that can run .getParentWindow to manipulate its position dynamically.  
ON popup

```auto
event.source.newMethod(event) #or event object
```

#IN custom method

```auto
include system
window = system.gui.getParentWindow(event) # or (self) or self.actionPerformed.source
print window.name
```

What is the best practice to store a method (at what level) to help avoid this? Or is there a cleaner way to target the parent window so I can move or adjust it without having hard coded paths?

I am starting to think I should just avoid Ignitions custom methods all together and just create and include everything in librarys on a repo at the server level.

---

<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 14, 2022, 12:03pm UTC](https://forum.inductiveautomation.com/t/event-source-or-system-gui-strange-error/61783/6 "2022-07-14T12:03:32Z")

</div>

I rarely use custom methods. I am a big fan of well-organized project library scripts. I like delegating events to such scripts with one-liners in each relevant event. Pass anything you need from the event context to the library function as arguments.

Under the hood, getParentWindow uses [SwingUtilities.getAncestorOfClass()](https://docs.oracle.com/en/java/javase/11/docs/api/java.desktop/javax/swing/SwingUtilities.html#getAncestorOfClass(java.lang.Class,java.awt.Component)). You can do the same in a library function if you have a special case.

---

<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 14, 2022, 12:05pm UTC](https://forum.inductiveautomation.com/t/event-source-or-system-gui-strange-error/61783/7 "2022-07-14T12:05:36Z")

</div>

Oh, and I wouldn’t hold your breath for a `PyComponentWrapper` fix. Items that a) have a work-around (my Simulation Aids) and b) are Vision have a relatively low priority.
