getFullScreenSize for buildWindow()

Post any questions, ideas, or topics related to Jython and Python scripting.
Post Reply
User avatar
joleenf
Posts: 1123
Joined: Mon Jan 19, 2009 7:16 pm

getFullScreenSize for buildWindow()

Post 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
User avatar
bobc
Posts: 990
Joined: Mon Nov 15, 2010 5:57 pm

Re: getFullScreenSize for buildWindow()

Post 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
User avatar
joleenf
Posts: 1123
Joined: Mon Jan 19, 2009 7:16 pm

Re: getFullScreenSize for buildWindow()

Post 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
User avatar
joleenf
Posts: 1123
Joined: Mon Jan 19, 2009 7:16 pm

Re: getFullScreenSize for buildWindow()

Post 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
User avatar
bobc
Posts: 990
Joined: Mon Nov 15, 2010 5:57 pm

Re: getFullScreenSize for buildWindow()

Post 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
User avatar
joleenf
Posts: 1123
Joined: Mon Jan 19, 2009 7:16 pm

Re: getFullScreenSize for buildWindow()

Post by joleenf »

Hi Bob,

The values returned from getSize are returning 0,0.

Joleen
User avatar
bobc
Posts: 990
Joined: Mon Nov 15, 2010 5:57 pm

Re: getFullScreenSize for buildWindow()

Post 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
User avatar
bobc
Posts: 990
Joined: Mon Nov 15, 2010 5:57 pm

Re: getFullScreenSize for buildWindow()

Post 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
User avatar
joleenf
Posts: 1123
Joined: Mon Jan 19, 2009 7:16 pm

Re: getFullScreenSize for buildWindow()

Post 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
Post Reply