# Docking a control relative to screen size

**URL:** <https://forum.inductiveautomation.com/t/docking-a-control-relative-to-screen-size/7073>\
**Category:** General Discussion\
**Created:** [August 18, 2013, 6:12pm UTC](https://forum.inductiveautomation.com/t/docking-a-control-relative-to-screen-size/7073 "2013-08-18T18:12:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sir\_Hacksalot](https://avatars.discourse-cdn.com/v4/letter/s/46a35a/32.png) [@Sir\_Hacksalot](https://forum.inductiveautomation.com/u/Sir_Hacksalot)\
**Post date:** [August 18, 2013, 6:12pm UTC](https://forum.inductiveautomation.com/t/docking-a-control-relative-to-screen-size/7073/1 "2013-08-18T18:12:08Z")

</div>

I would like to create a collection of controls that scale relative to one another.

Since I do not have a _fill_ anchor setting, I cannot access h/w from script for container objects, and there is no resize event…

The final control will be more complex, but in its most simple form, imagine a container I wanted to have two distinct sections divided at half window width.

The final control will have selection buttons and screen displays, I want the buttons to stay their designed h/w the text displays I want to scale into the available space.

Suggestions or just no such creature?

---

<div class="post-metadata">

**Author:** ![Sir\_Hacksalot](https://avatars.discourse-cdn.com/v4/letter/s/46a35a/32.png) [@Sir\_Hacksalot](https://forum.inductiveautomation.com/u/Sir_Hacksalot)\
**Post date:** [August 18, 2013, 6:45pm UTC](https://forum.inductiveautomation.com/t/docking-a-control-relative-to-screen-size/7073/2 "2013-08-18T18:45:14Z")

</div>

It looks like I may be able to do this with nested templates.

In the mean time if there are any other suggestions feel free to contribute.

---

<div class="post-metadata">

**Author:** ![Robert.McKenzie](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/robert.mckenzie/32/4134_2.png) [@Robert.McKenzie](https://forum.inductiveautomation.com/u/Robert.McKenzie)\
**Post date:** [December 23, 2013, 11:10pm UTC](https://forum.inductiveautomation.com/t/docking-a-control-relative-to-screen-size/7073/3 "2013-12-23T23:10:50Z")

</div>

Well, there’s a little script you can do to resize your containers when the window opens, but that requires that you use the invokeLater() function to get the timing right. Try putting this script into your window’s visionWindowOpened event. (You need to change the names for your containers though).

[code]def resizeContainers(event=event):  
import system  
# get the height and width  
height = event.source.height  
width = event.source.width

```
# set the containers to half the width of the screen
# use system.gui.reshapeComponent(comp,x,y,width,height)
container1 = event.source.getRootContainer().getComponent('Left Container')
container2 = event.source.getRootContainer().getComponent('Right Container')
system.gui.reshapeComponent(container1,0,0,width/2,height)
system.gui.reshapeComponent(container2,width/2,0,width/2,height)

```

system.util.invokeLater(resizeContainers)[/code]
