Page 1 of 1

getFullScreenSize for buildWindow()

Posted: Mon Feb 08, 2016 6:14 pm
by joleenf
Hi,

I am writing a script and in one module want to get the screen size of the current panel. I could carry around the values for height and width that I set at the beginning of the script, but I thought the more stable way would be to use

panel.getFullScreenSize(). Unfortunately, on a panel that was created using buildWindow, I am getting (0,0). Is there a way to get the set height and width of a buildWindow panel without carrying around the user defined variables? (get it from the object attributes instead).

Joleen

Re: getFullScreenSize for buildWindow()

Posted: Tue Feb 09, 2016 6:33 pm
by bobc
Hi Joleen -

getFullScreenSize() returns the values that you have set in View>Properties under 'Full Screen Dimensions'. These text box fields set the size of the window when you go to View>Full Screen. By default, these text boxes are left empty so the going to full screen will take up the full monitor. Another way of doing this is setting both height and width to '0'. It looks like getFullScreenSize() is pulling the '0' values from here.

If you want to get the actual dimensions of the panel, you can use getDimensions(). This returns a list of 4 numbers, where the third number is width and the fourth number is height. To pull the width and height info into variables, you can do something like the following:

Code: Select all

myWin = buildWindow(height=900, width=1400)
myWinSize = myWin[0].getDimensions()
myWinWidth = myWinSize[2]
myWinHeight = myWinSize[3]
print 'myWin width = %s' %myWinWidth
print 'myWin height = %s' %myWinHeight

This returns:
myWin width = 1400
myWin height = 900

Does this get you what you are looking for?

Thanks -
Bob Carp

Re: getFullScreenSize for buildWindow()

Posted: Wed Feb 10, 2016 3:06 pm
by joleenf
Yes Bob, this does work. In fact panel.getSize() also works, it is just that I was running into the same problem I had when I posted this question:

http://mcidasv.ssec.wisc.edu/forums/vie ... ff73a586f6

The width I set was too small to contain all my toolbar buttons, so I was not seeing the width I thought I set of 500 px, because I need 514 px to contain the toolbar as well.

Joleen

Re: getFullScreenSize for buildWindow()

Posted: Mon Feb 15, 2016 6:11 pm
by joleenf
Hi Bob,

It seems that getSize works from the jython shell, but not when the script is run from the command line. I switched to getDimensions(). This seems to be working for both.

Joleen

Re: getFullScreenSize for buildWindow()

Posted: Mon Feb 15, 2016 7:15 pm
by bobc
Hi Joleen -

I created a basic script that I've run in the background using today's nightly on Windows 7 and OS X and in both cases getSize appears to be working. Here's what I'm doing:

Code: Select all

panel = buildWindow(height=800,width=1000)

getSizeVals = panel[0].getSize()
getSizeWidth = getSizeVals[0]
getSizeHeight = getSizeVals[1]

panel2 = buildWindow(height=int(getSizeHeight),width=int(getSizeWidth))
panel2[0].captureImage('C:/Users/rcarp/getSize.jpg')

The image of panel 2 has a width of 1000 pixels and a height of 800 pixels. I'm assuming that you are doing something more complex than this to make getSize not work? Also, when it doesn't work, do you get an error or are the size values just not correct?

Thanks -
Bob Carp

Re: getFullScreenSize for buildWindow()

Posted: Tue Feb 16, 2016 2:08 am
by joleenf
Hi Bob,

The values returned from getSize are returning 0,0.

Joleen

Re: getFullScreenSize for buildWindow()

Posted: Tue Feb 16, 2016 8:16 pm
by bobc
Thanks, Joleen. I wasn't actually trying to print out the getSize values, but I'm now seeing that these are returning 0, 0 from the background. Surprisingly, these values can be passed into buildWindow and they work as expected. Since the getSize values are incorrectly returned as 0, 0, I wrote up Inquiry 2267.

- Bob

Re: getFullScreenSize for buildWindow()

Posted: Wed Feb 24, 2016 4:04 pm
by bobc
Hi Joleen -

Out of curiosity, why do you use full screen mode and not just the window from buildWindow as-is? Is it just so you can create windows with a width narrower than the main toolbar, or are there other reasons as well?

Thanks -
Bob

Re: getFullScreenSize for buildWindow()

Posted: Wed Feb 24, 2016 6:38 pm
by joleenf
Hi Bob,

I am using the buildWindow screen. However, I wanted a stable way of getting the actual window size rather than remembering to pass the value from one module to another. The code I using right now generates images with many different screen sizes. I could just pass the values as they change, or get them from the system. It seemed to me that it was safer to ask McIDAS-V what the display size is rather than passing a variable.

Joleen