# Custom properties as PyObjects

**URL:** <https://forum.inductiveautomation.com/t/custom-properties-as-pyobjects/18558>\
**Category:** Ignition\
**Tags:** ignition79, scripting\
**Created:** [June 21, 2018, 1:38pm UTC](https://forum.inductiveautomation.com/t/custom-properties-as-pyobjects/18558 "2018-06-21T13:38:17Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![pgmo](https://avatars.discourse-cdn.com/v4/letter/p/d07c76/32.png) [@pgmo](https://forum.inductiveautomation.com/u/pgmo)\
**Post date:** [June 21, 2018, 1:38pm UTC](https://forum.inductiveautomation.com/t/custom-properties-as-pyobjects/18558/1 "2018-06-21T13:38:17Z")

</div>

As far as I see there’s no possibility to pass a variable to a page through the **Custom Properties** mechanism that is a `PyObject`. That would be of use if I need to pass a reference to the current popup window to a new popup window, which I open from the first one - at the moment I store a reference of the first popup window in a python script variable.  
Any suggestion?

Thanks in advance, regards

---

<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:** [June 21, 2018, 1:40pm UTC](https://forum.inductiveautomation.com/t/custom-properties-as-pyobjects/18558/2 "2018-06-21T13:40:13Z")

</div>

The only safe place to put a pyobject is using Swing’s ‘Client Properties’ of jcomponents and jframes.

---

<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:** [June 21, 2018, 1:42pm UTC](https://forum.inductiveautomation.com/t/custom-properties-as-pyobjects/18558/3 "2018-06-21T13:42:48Z")

</div>

If you put a parent window reference in a popup’s client properties, be sure to use a weak reference instead of the window object itself. Otherwise you risk leaking memory.

---

<div class="post-metadata">

**Author:** ![pgmo](https://avatars.discourse-cdn.com/v4/letter/p/d07c76/32.png) [@pgmo](https://forum.inductiveautomation.com/u/pgmo)\
**Post date:** [June 21, 2018, 2:05pm UTC](https://forum.inductiveautomation.com/t/custom-properties-as-pyobjects/18558/4 "2018-06-21T14:05:47Z")

</div>

> [@pturmel](#):
>
> The only safe place to put a pyobject is using Swing's 'Client Properties' of jcomponents and jframes.

Thanks pturmel! I'm trying to elaborate on your valuable suggestion, but I'm facing the problem I describe next. I've defined **Popup1** and **Popup2** : a button on Popup1 opens Popup2 and calls `putClientProperty` on the newly created Popup2

```auto
window = system.nav.openWindow('Popup2')
window.putClientProperty("winRef",system.gui.getParentWindow(event))

```

On Popup1 I've also defined a Custom Method `sayHello()`: if I try to call sayHello() from a button on Popup2

```auto
system.gui.getParentWindow(event).getClientProperty("winRef").sayHello()

```

I get the exception:  
`AttributeError: 'com.inductiveautomation.factorypmi.application.FPM' object has no attribute 'sayHello'`

Any idea?

Thanks in advance

**UPDATE**  
If I pass the reference to **Popup1** through a `shared.test.win` variable in the shared _test_ script, then **Popup2** will manage to call `sayHello()` on Popup1.

**UPDATE2**  
Same effect if the `sayHello()` Custom Method is defined at the **Root Container** level, instead of the **Window** level. It behaves as the reference stored in the Client Property looses the Custom Methods. Do I have to cast the object I get with the `getClientProperty` call?

---

<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:** [June 21, 2018, 2:32pm UTC](https://forum.inductiveautomation.com/t/custom-properties-as-pyobjects/18558/5 "2018-06-21T14:32:35Z")

</div>

You are suffering from a limitation of Ignition’s python wrappers. See [this topic](http://forum.inductiveautomation.com/t/transaction-groups-triggered-expression-item-updating-when-trigger-is-false/17196/19) and try the most recent [release candidate](https://www.automation-pros.com/ignition/Simulation%20Aids-1.7.7.1806081654.modl) of Simulation Aids.
