system.gui.setScreenIndex()

Hi there,

has anyone used the new multi screen feature in 7.9?

system.gui.setScreenIndex()

I’m trying to use this in a project and I cannot find how to use it properly.

I have two displays on my desktop and using the “system.gui.getScreens()” I get this result [(0, 1920, 1200), (1, 1920, 1200)] , so I can use index 0 and 1.

Can someone point me in the right direction, where should I use the .setScreenIndex script to open one window for each display?

Thank you

I made a mistake, the correct command that I should use is: system.gui.openDesktop().
with this I managed to open a new window frame, now I need to find out how to open a window in that frame…

Correct, you want openDesktop, not setScreenIndex.

The arguments to openDesktop should show up in the pop-up documentation. Here’s how you’d open an additional desktop on screen 1 and open two windows:

system.gui.openDesktop(screen=1, windows=["Window 1", "Window 2"])

you can also give the desktop a “handle” which is like a name or ID. If you don’t give it one, then the screen index is used. This handle can then be used with the desktop function to send commands to other desktops. For example, if you wanted to click a button on screen 0 that performed a swap on the desktop you’d previously opened on screen 1, you could do:

system.nav.desktop(1).swapTo("Something")

Let me know if you have any more questions, and check out the docs that you get when you hit CTRL-Space in the script editor.

I have a relevant question that might help me and other folks. I’m trying to utilize the new multi-monitor functionality and am having trouble with the CurrentWindow system. It seems as though [Client]System/Client/User/CurrentWindow is always driven by the Primary Desktop (which aligns with the documentation statements about client tags being shared amongst desktops). However, how can I determine the handle and/or screen-index of a given desktop (from the context of that desktop).

I thought that system.nav.desktop().getCurrentWindow() would return a system.nav object relative to the calling desktop, but it goes back to the Primary Desktop (the documentation suggests this, but I was hoping that was in-error, as it indicates you can use the “primary” handle to refer to the Primary Desktop). I have to specify it by name, but I have no way to easily pass the handle to the launched desktop to give it implicit knowledge of who “it” is.

Is there another way I can bind to the current window within a given desktop (so I can have independent navigation)?

Let me know if I’m unclear on any of this. Thanks for any help you can provide.

from com.inductiveautomation.factorypmi.application import VisionDesktop print VisionDesktop.CURRENT_DESKTOP.get()

This will return the ‘desktop’ handle wherever the script was executed.

1 Like

How can we use the handle of a desktop to get access to a window instance on that desktop?
For instance trying to set a property value of something on the new desktop windows root container?
I tried using:

window = system.gui.getWindow(system.nav.desktop(handlerName).getCurrentWindow())

But when i use that to change a component property, its just pointing back to the Primary Desktops window.

What about using something like this (I haven’t tested this code, just referencing the documentation):

from com.inductiveautomation.factorypmi.application import VisionDesktop
window = system.nav.desktop(VisionDesktop.CURRENT_DESKTOP.get()).getCurrentWindow()

The system.nav.desktop function returns a nav instance (and accepts a handle parameter) that you can then use (from whichever desktop context you retrieved) to execute nav functions like system.nav.getCurrentWindow().

Let me know if this works for you, I hope it helps.

3 Likes