# Custom confirmation window

**URL:** <https://forum.inductiveautomation.com/t/custom-confirmation-window/15592>\
**Category:** Ignition\
**Created:** [October 6, 2017, 11:43am UTC](https://forum.inductiveautomation.com/t/custom-confirmation-window/15592 "2017-10-06T11:43:20Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kleppe85](https://avatars.discourse-cdn.com/v4/letter/k/c4cdca/32.png) [@Kleppe85](https://forum.inductiveautomation.com/u/Kleppe85)\
**Post date:** [October 6, 2017, 11:43am UTC](https://forum.inductiveautomation.com/t/custom-confirmation-window/15592/1 "2017-10-06T11:43:20Z")

</div>

Hi,  
I’m trying to make a custom confirmation window for my application. But I can’t figure out how to make a window return a value. Has anyone figured out a “simple” way to do this? or is it best to just stick with system.gui.confirm() ?

---

<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:** [October 6, 2017, 12:46pm UTC](https://forum.inductiveautomation.com/t/custom-confirmation-window/15592/2 "2017-10-06T12:46:46Z")

</div>

The simplest way would be to have custom parameters on the root of the confirm window that specify a window name and property name the confirmation window should look up and write to with its result. The caller would supply its own name and a suitable property when opening the confirm window, then catch the result with a propertyChange event.  
This won’t work if there can be multiple instances of the calling window – you’d need some kind of callback registry in a script module. If you have to go that route, be sure to use the weakref module to hold window objects.

---

<div class="post-metadata">

**Author:** ![erfritts](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/erfritts/32/3660_2.png) [@erfritts](https://forum.inductiveautomation.com/u/erfritts)\
**Post date:** [October 6, 2017, 1:03pm UTC](https://forum.inductiveautomation.com/t/custom-confirmation-window/15592/3 "2017-10-06T13:03:14Z")

</div>

I’m not nearly as experienced as pturmel, but I like it Barney style. I use a client tag Boolean. I write to it with a button on my custom popup and rewrite the tag with a propertyChange event attached to the source which fired the confirmation sequence.

---

<div class="post-metadata">

**Author:** ![Kleppe85](https://avatars.discourse-cdn.com/v4/letter/k/c4cdca/32.png) [@Kleppe85](https://forum.inductiveautomation.com/u/Kleppe85)\
**Post date:** [October 7, 2017, 9:03am UTC](https://forum.inductiveautomation.com/t/custom-confirmation-window/15592/4 "2017-10-07T09:03:10Z")

</div>

Thanks for the advice. I got it working now. I don’t think I will get a problem with multiple instances. But just out of curiosity, do you have a example (for dummies) of using weakref module with a Ignition object?

---

<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:** [October 7, 2017, 3:05pm UTC](https://forum.inductiveautomation.com/t/custom-confirmation-window/15592/5 "2017-10-07T15:05:30Z")

</div>

> [@Kleppe85](#):
>
> do you have a example

Not handy, no. Or I would have posted it. Instead of just brainstorming in public. (-:

---

<div class="post-metadata">

**Author:** ![systemparadox](https://avatars.discourse-cdn.com/v4/letter/s/b5e925/32.png) [@systemparadox](https://forum.inductiveautomation.com/u/systemparadox)\
**Post date:** [November 2, 2017, 4:46pm UTC](https://forum.inductiveautomation.com/t/custom-confirmation-window/15592/6 "2017-11-02T16:46:15Z")

</div>

I was just about to implement a full callback mechanism for this when I had a thought - now that we have custom functions, we can use Phil’s property idea, but get it to call a custom function on the window instead…

The custom popup has callbackWindow and callbackProperty (both strings), which are passed by the parent window like this:

```auto
system.nav.openWindow('Custom popup', {
	'callbackWindow': 'Parent window',
	'callbackProperty': 'callback',
})

```

Then the save button for the custom popup does this:

```auto
root = system.gui.getParentWindow(event).getRootContainer()
fn = getattr(system.gui.getWindow(root.callbackWindow), root.callbackProperty)
fn(result)

```

Which calls the `callback` custom function defined on ‘Parent window’:

```auto
def callback(self, result):
    # Do something with result

```

This seems to work well. It’s far easier than a full callback system with weakrefs and far better than messing around with propertyChange events (which tend to fire too often, like when the window is opened or the project is updated).

---

<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:** [November 2, 2017, 7:57pm UTC](https://forum.inductiveautomation.com/t/custom-confirmation-window/15592/7 "2017-11-02T19:57:03Z")

</div>

That’s pretty close to the “simplest way” that I suggested, but with a custom method instead of a propertyChange event. What it lacks is any way to use this when the calling window is one of multiple instances. That’s where the suggestion to use weakrefs to actual window objects comes in. For the pedants among us. (-:

---

<div class="post-metadata">

**Author:** ![cmisztur2](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmisztur2/32/4243_2.png) [@cmisztur2](https://forum.inductiveautomation.com/u/cmisztur2)\
**Post date:** [November 7, 2017, 1:36pm UTC](https://forum.inductiveautomation.com/t/custom-confirmation-window/15592/8 "2017-11-07T13:36:17Z")

</div>

Attached is what I am using to authorize a user within the application and execute code on success or failure.

calling:

```auto
window = system.nav.openWindow('WindowsAuthorization', {'Role':'SMF-Ignition-Admin'})
window.setActions(lambda caller: system.nav.openWindow('LaneManagement2'))

```

[TEMPLATE\_1\_WindowsAuthorization\_2017-11-07\_0734.proj](https://us1.discourse-cdn.com/inductiveautomation/original/2X/8/838266be1149fcf250f68a236cbca032dd4a49d2.proj) (11.0 KB)

---

<div class="post-metadata">

**Author:** ![dmdrendall](https://avatars.discourse-cdn.com/v4/letter/d/f9ae1b/32.png) [@dmdrendall](https://forum.inductiveautomation.com/u/dmdrendall)\
**Post date:** [July 13, 2018, 9:19pm UTC](https://forum.inductiveautomation.com/t/custom-confirmation-window/15592/9 "2018-07-13T21:19:48Z")

</div>

I’m not worthy. Any of you guys do jobs on the side for coffee and doughnuts?

Thanks for the ideas!!

---

<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 13, 2018, 10:37pm UTC](https://forum.inductiveautomation.com/t/custom-confirmation-window/15592/10 "2018-07-13T22:37:10Z")

</div>

I’ve been known to do things for pizza and beer… (-:

---

<div class="post-metadata">

**Author:** ![cmisztur2](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmisztur2/32/4243_2.png) [@cmisztur2](https://forum.inductiveautomation.com/u/cmisztur2)\
**Post date:** [July 14, 2018, 12:24am UTC](https://forum.inductiveautomation.com/t/custom-confirmation-window/15592/11 "2018-07-14T00:24:25Z")

</div>

Beer and friends sounds fine
