Scripting with the window size

Hi all,

I need to know the size of the main window that the Client is seeing to know the resolution of his monitor. I have used [color=#0000FF]"aux = event.source.parent.parent.parent.parent.size"[/color] but it returns a "Dimension" type, so I can't read the width and height or use string replace or something...

Any idea? Thanks a lot.

Raul.

How about this:

h=event.source.parent.parent.parent.parent.size.height
w=event.source.parent.parent.parent.parent.size.width

[quote=“r.dominguez”]
I need to know the size of the main window that the Client is seeing to know the resolution of his monitor…[/quote]

Just to stress a perhaps minor point, the window will be smaller than screen resolution. It will be affected if something like the menu bar is showing.

Hope this helps!

Sorry, couldn’t let this one pass…

This one will get screen resolution for you.

import java.awt
gd=java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice()
width = gd.getDisplayMode().getWidth()
height = gd.getDisplayMode().getHeight()

Hi Jordan,

thanks for all the replies! This one did the trick!!

[color=#0000FF]size_string1 = event.source.parent.parent.parent.parent.height
size_string2 = event.source.parent.parent.parent.parent.width

event.source.parent.getComponent(‘Label 2’).text = str(size_string1)
event.source.parent.getComponent(‘Label 3’).text = str(size_string2)[/color]

Thanks again!!

does it works only in vision ? or perspective too ? because i m getting exact my system display resolution from vision but not in perspective as it is returning some different ..
system display resolution is : 1366 * 768
Vision o/p: 1366 * 768
Perspective o/p: 1024*768

Please help to get same in perspective too

Won't work with perspective. NOTHING related to display is common between vision and perspective. Two very, VERY different technologies.

What exactly do you want to do ?

1 Like

Thanks for your response. I want to get my system display resolution to set height and width based on that value ..so that the screen will be visible same as mine(height and width will be same as per system display resolution) ..

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 think this should be split off to a separate thread. The original question was in 2013 when Perspective didn't exist. Reference this thread if it's relevant (which it isn't).

What is "height n width"? If it's "height and width" then write that to avoid confusion. If not then please explain.

2 Likes