# Equipment Scheduler event popup trigger

**URL:** <https://forum.inductiveautomation.com/t/equipment-scheduler-event-popup-trigger/63030>\
**Category:** Ignition\
**Tags:** vision\
**Created:** [August 16, 2022, 9:31am UTC](https://forum.inductiveautomation.com/t/equipment-scheduler-event-popup-trigger/63030 "2022-08-16T09:31:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dharani\_T](https://avatars.discourse-cdn.com/v4/letter/d/bc8723/32.png) [@Dharani\_T](https://forum.inductiveautomation.com/u/Dharani_T)\
**Post date:** [August 16, 2022, 9:31am UTC](https://forum.inductiveautomation.com/t/equipment-scheduler-event-popup-trigger/63030/1 "2022-08-16T09:31:24Z")

</div>

Hi,  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/f/9/f94e535e0b94305dfffa6949422e2947eafa6daa.png)  
I have created a popup in equipment scheduler, in which on click on the popup , the event should be deleted. However, this logic is working even when not clicked on the popup. Please refer the attached picture for reference,

Thanks in advance

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [August 16, 2022, 11:48am UTC](https://forum.inductiveautomation.com/t/equipment-scheduler-event-popup-trigger/63030/2 "2022-08-16T11:48:13Z")

</div>

Please don’t post snap shots of code, instead copy and paste the code and then use the preformatted text option `</>`. This will make it so that the code retains its formatting and other users can easily copy your code to test or modify.

I assume that what you are really want to happen is that when the menu button is click to run the named query, and then display the message box.

You have a few problems:

1. The `system.gui.createPopupMenu()` takes two lists as parameters, you have provided a single dictionary
2. The script you want to execute should be within the function that you have assigned to that menu item.

```python
def deleteSchedule(event,machID = eventId):
    dlparams = {'iMachineID':machID}
    system.db.runNamedQuery('Scheduler/deleteSchedule',dlparams)
    system.guil.messageBox('You deleted event for {}'.format(machID))

names = ['Delete']
functions = [deleteSchedule]
menu = system.gui.createPopupMenu(names,functions)
menu.show(event)

```

You can see more examples on how to use the Popup menu in the manual.  
[https://docs.inductiveautomation.com/display/DOC81/system.gui.createPopupMenu](https://docs.inductiveautomation.com/display/DOC81/system.gui.createPopupMenu)

Also, generally having any type of “delay” on the GUI is not recommended, even though you have done it in a thread safe way, I’m not sure what the purpose of waiting 2.5 seconds to refresh is.

---

<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:** [August 16, 2022, 9:11pm UTC](https://forum.inductiveautomation.com/t/equipment-scheduler-event-popup-trigger/63030/3 "2022-08-16T21:11:44Z")

</div>

You are stopping your timer right after you start it, so it will never execute your function. You can’t call an component methods from another thread anyways (lockup risk), so it is probably just as well that it didn’t work. Use the delay argument to `system.util.invokeLater` instead.

{ Don’t use timers or threads or any sleep calls from jython’s standard library. Use Ignition’s script functions and/or native java classes. }
