How to get system display resolution in perspective

https://forum.inductiveautomation.com/t/scripting-with-the-window-size/6145/6?u=manjuyadav95.m

I'm getting my system display resolution from vision but not in perspective as it is returning some different resolution ..
system display resolution is : 1366 * 768
Vision o/p: 1366 * 768
Perspective o/p: 1024*768

below code worked in vision but giving different values when used in perspective.. please help

gd=java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice()
width = gd.getDisplayMode().getWidth()
height = gd.getDisplayMode().getHeight()
print('width',width,' height',height)
window=system.gui.getParentWindow(event)
window.setSize(int(round(width*0.25)), int(round(height*0.65)))

I can't see how this would be working at all I Perspective since this library (gui) is for Vision only. In Perspective you can just read the various page props. If you add a property binding on the view, expand the 'page' root prop

2 Likes

expanded page prop but its width is 0 returning in expression binding o/p

The values don't update in the designer because it doesn't have any concept of a page. Try to put this binding on a label and opening it in a browser, you should see values update there.

'Viewport Width: ' + {page.props.dimensions.viewport.width} + ' Height: ' + {page.props.dimensions.viewport.height}

1 Like