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

**URL:** <https://forum.inductiveautomation.com/t/when-does-a-window-get-resized-to-fit-a-screen-vs-events/5378>\
**Category:** Ignition\
**Created:** [November 5, 2012, 6:44pm UTC](https://forum.inductiveautomation.com/t/when-does-a-window-get-resized-to-fit-a-screen-vs-events/5378 "2012-11-05T18:44:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Robert](https://avatars.discourse-cdn.com/v4/letter/r/e95f7d/32.png) [@Robert](https://forum.inductiveautomation.com/u/Robert)\
**Post date:** [November 5, 2012, 6:44pm UTC](https://forum.inductiveautomation.com/t/when-does-a-window-get-resized-to-fit-a-screen-vs-events/5378/1 "2012-11-05T18:44:31Z")

</div>

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

```auto
    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?

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [November 5, 2012, 6:51pm UTC](https://forum.inductiveautomation.com/t/when-does-a-window-get-resized-to-fit-a-screen-vs-events/5378/2 "2012-11-05T18:51:32Z")

</div>

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)`

---

<div class="post-metadata">

**Author:** ![Robert](https://avatars.discourse-cdn.com/v4/letter/r/e95f7d/32.png) [@Robert](https://forum.inductiveautomation.com/u/Robert)\
**Post date:** [November 5, 2012, 11:11pm UTC](https://forum.inductiveautomation.com/t/when-does-a-window-get-resized-to-fit-a-screen-vs-events/5378/3 "2012-11-05T23:11:20Z")

</div>

That was it. Thanks Travis
