How to get window custom property for each window Instances

I have a used a custom property of window to find weather that window is pinned or not.
When i click on Button, it go through below script and find all opened window, points to the custom property.
However for the instance of same window it doesn't work. it reads the same value as previous for instance of window.

#Get Windows name that button is on
WindowName = system.gui.getParentWindow(event)
#Get Current maximize window name
CWindowName = system.nav.getCurrentWindow()
#Convert to String
stringsearch = str(WindowName)

#Check if it a drop Menu configuration
if event.source.parent.parent.DropMenu==False:
#This is NOT a drop menu
#Search String for drop menu, then close drop menu
if stringsearch.find("Menu_") > -1:
#Close Parent window
system.nav.closeWindow(WindowName)

#Close All open Pop ups # change v2.1.221012
 #Get all open window names
windows = system.gui.getOpenedWindowNames()
#system.gui.messageBox( 'There are %d windows open' % len(windows))
for path in windows:
	 window= system.gui.getWindow(path)
	 system.gui.messageBox( str(window))
	 if  path != CWindowName and window != WindowName :
	 	WinPinned= window.getRootContainer().temp_WinPin
	 	system.gui.messageBox( str(WinPinned))
		if WinPinned is False:
			system.nav.closeWindow(window)

Don't use system.gui.getOpenedWindowNames(). That obviously can't distinguish between multiple windows of the same name. Instead, use system.gui.getOpenedWindows(), which delivers all of the window objects present. Check each window object's .path property to see which it is. Use that object's .rootContainer to then inspect its contents.

4 Likes

Thanks. Its working now!

Hi, I want to do the same thing in Perspective.
what can I use instead of "system.gui.getOpenedWindowNames()", as this not perspective supported function.

Perspective doesn't have windows. It has pages and views. Look under the system.perspective. section of the manual for alternatives. (They won't work the same way. That is, you won't get page or view objects. Perspective doesn't expose those.)

1 Like

Hi,

I write down following script to find open Pages in Current Session.
See Attached image.
though I can only list PageIds for open pages.
How can I access each page using this page ID list.

You can't. Perspective only exposes its objects within the relevant environment. Send a message with the proper scope to each page. Do the per-page logic in a message handler within the page.

Hi,

Can you Elaborate more?
I just need any popup (View instance) to be identified for closing it when change main window/view.