# Popup Menu From Alarm Status Table

**URL:** <https://forum.inductiveautomation.com/t/popup-menu-from-alarm-status-table/75452>\
**Category:** Ignition\
**Tags:** ignition81, vision, scripting\
**Created:** [June 23, 2023, 1:27pm UTC](https://forum.inductiveautomation.com/t/popup-menu-from-alarm-status-table/75452 "2023-06-23T13:27:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rfolkes](https://avatars.discourse-cdn.com/v4/letter/r/e95f7d/32.png) [@rfolkes](https://forum.inductiveautomation.com/u/rfolkes)\
**Post date:** [June 23, 2023, 1:27pm UTC](https://forum.inductiveautomation.com/t/popup-menu-from-alarm-status-table/75452/1 "2023-06-23T13:27:51Z")

</div>

Ignition 8.1 / Vision / Component Alarm Status table.

My goal is to make a right click menu popup that allows for a couple of options based on some custom parameters in the alarm.

```auto
def createPopupMenu(self, selectedAlarmEvents):
	names = []
	funcs = []
	
	InputNum = selectedAlarmEvents[0].get("Number")
	PLC = selectedAlarmEvents[0].get("PLC")
	Provider = selectedAlarmEvents[0].get("Provider")
	path = "Popups/Inputs"
	params = {"PLC":PLC, "Provider":Provider, "InputNum":InputNum }
	
	
	
	def OpenDrill(event):
		import system
		system.nav.openWindow("Main Windows/Site/FAB1/Level 1/Sector 1")
	names.append("Go to Page")
	funcs.append(OpenDrill)
	
	def OpenPopup(path, params):
		import system
		system.nav.openWindow(path, params)
	names.append("Open Input Popup")
	funcs.append(OpenPopup(path, params))	

	menu = system.gui.createPopupMenu(names, funcs)
	return menu

```

what happens with this is that the OpenPopup portion fires and opens the correct popup when right click is done to bring up menu. Never really see the menu it just instantly navigates. So I guess I am missing something in function to wait for click... not sure what though.

Also,  
With this it depends on a single alarm being "selected" on the table. Is there a way to make this work without the selection so that it is based on the alarm that is under the right click only?

---

<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:** [June 23, 2023, 4:06pm UTC](https://forum.inductiveautomation.com/t/popup-menu-from-alarm-status-table/75452/2 "2023-06-23T16:06:02Z")

</div>

> [@rfolkes](#):
>
> ```auto
> funcs.append(OpenPopup(path, params))	
> 
> ```

That's the core problem.

You need to pass a _callable reference_ to your function - what you're doing is _calling your function_, which is why it immediately opens the popup. A complication is that `system.gui.createPopupMenu` expects your function to accept one argument (for an event object) and nothing else. So, one option you have is to use Python's builtin `functools` module, specifically the `partial` function: [9.8. functools — Higher-order functions and operations on callable objects — Python 2.7.18 documentation](https://docs.python.org/2.7/library/functools.html#functools.partial)

> The [`partial()`](https://docs.python.org/2.7/library/functools.html#functools.partial) is used for partial function application which “freezes” some portion of a function’s arguments and/or keywords resulting in a new object with a simplified signature. For example, [`partial()`](https://docs.python.org/2.7/library/functools.html#functools.partial) can be used to create a callable that behaves like the [`int()`](https://docs.python.org/2.7/library/functions.html#int) function where the _base_ argument defaults to two:

Which you could then use to wrap a simple function that calls openWindow. Putting it all together, it would look something like this:

```python
def createPopupMenu(self, selectedAlarmEvents):
	names = []
	funcs = []
	from functools import partial	
	def openWindow(event, path, params = None):
		system.nav.openWindow(path, params or {})
		
	names.append("Go to Page")
	funcs.append(partial(openWindow, path="Main Windows/Site/FAB1/Level 1/Sector 1"))
	
	params = {
		"PLC": selectedAlarmEvents[0].get("PLC"),
		"Provider": selectedAlarmEvents[0].get("Provider"),
		"InputNum": selectedAlarmEvents[0].get("Number")
	}
	
	names.append("Open Input Popup")
	funcs.append(partial(openWindow, path="Popups/Inputs", params=params))

	return system.gui.createPopupMenu(names, funcs)

```

> [@rfolkes](#):
>
> With this it depends on a single alarm being "selected" on the table. Is there a way to make this work without the selection so that it is based on the alarm that is under the right click only?

Yes, but it's not trivial. The `event` object delivered to you in the createPopupMenu callback will have x and y coordinates on it. "Inside" the alarm status table are (technically, a couple) Java swing JTable components, which have a [`rowAtPoint()` method](https://docs.oracle.com/en/java/javase/11/docs/api/java.desktop/javax/swing/JTable.html#rowAtPoint(java.awt.Point)) to convert an x/y coordinate to a selected row on the table. The AST itself, meanwhile, has a [`viewRowToAlarm` function](https://files.inductiveautomation.com/sdk/javadoc/ignition81/8.1.27/com/inductiveautomation/factorypmi/application/components/alarm/AbstractAlarmTable.html#viewRowToAlarm(int)) to convert a row index to an actual selected alarm. With those things together, you should be able to take a click on the context menu, convert it into a row, convert that row into an alarm, and do something with that alarm. But it's not trivial.
