Preventing a popup window to open twice with same parameter, title

We do something similar.

This is a set of functions that we use to find a window and then look for a parameter named “Tag”. If that is found then the window isn’t opened again.

Originally we referenced this post: Nav Helper system.nav.openWindowInstace

window is the path to the popup
instanceId is the value of the tag that we are looking for. You can modify tag to be your unique parameter that is being passed.

# this finds a window based on the path passed and the Tag parameter
def findInstance(window,instanceId):
	import system
	for row in system.gui.getOpenedWindows():
		if row.getPath() == window and row.getRootContainer().Tag == instanceId:
			return row
	return None
	
#This will open an instance of the passed window
def openInstance(window,properties=None):
	import system
	windowInstance = findInstance(window,properties['Tag'])
	if windowInstance == None:
		windowInstance = system.nav.openWindowInstance(window,properties)
	#system.nav.centerWindow(windowInstance)
	windowInstance.toFront()
	windowInstance.setSelected(1)
	return windowInstance

#This will close an instance of the passed parameter
def closeInstance(window,instanceId):
	import system
	windowInstance = findInstance(window,properties['Tag'])
	if windowInstance != None:
		system.nav.closeWindow(windowInstance)
1 Like