When does a window get resized to fit a screen vs events?

I have a screen that has a number of components. The actual number that gets displayed depends on the size of the screen. This woks fine expect for the first time the screen is opened.

Here is the setup:
I have internal frame activated event that calls a python script (passing it the event). That script has the following code

    trend = event.source.rootContainer.getComponent('TrendGraph')
    height = trend.size.height

What happens:
If I put system.gui.messageBox("Trend height is: %s" % (height)) right after the above, I see that the screen first opens in the default size, runs the code above, then resizes to fit the available space. Of course by this time I have displayed the wrong number of components.

I tried putting the code in the Internal frame opened, by the screen is not resized when the code runs, and then the code never runs again.

Am I doing something wrong? Is this even possible?

You have to put your code in a system.util.invokeLater so we give it some time to layout the window first:def doLater(event=event): import system trend = event.source.rootContainer.getComponent('TrendGraph') height = trend.size.height system.util.invokeLater(doLater)

That was it. Thanks Travis