system.nav.getCurrentWindow() does not work in designer mode

system.util.getProjectName() works fine in designer but system.nav.getCurrentWindow() does not

Using 7.9

My work around:

With component “comp” from target window

from com.inductiveautomation.factorypmi.application import FPMIWindow
if system.util.getSystemFlags() & system.util.DESIGNER_FLAG:
	while not  isinstance(comp.parent,FPMIWindow):
		comp=comp.parent
	curWindow=comp.parent.getPath()
else:
	curWindow=system.nav.getCurrentWindow()

That is a nice workaround for testing functions using this method in the designer.

Just to be clear, this is the expected behavior since getCurrentWindow() returns the path to the currently maximized window, and the designer does not display maximized windows.

For completeness, I would also like to mention that, in cases where the script is called from a component event, system.gui.getParentWindow(event).getPath() can also be used.

2 Likes