PDA

View Full Version : Addstretch() function to help custom layouts



hmischel@diligentsystems.com
2016-08-25, 21:04
If you are like me and enjoy laying out containers, the addstretch() function is very handy.
Thanks to Barry for pointing that out to me today.
Here is an example.

In my center container, I have two buttons that are added in a Horizontal layout. They are spaced evenly as you would expect.
1360

If I add centercontainer.addstretch() before I add the buttons, it acts like a container and pushes the buttons to the bottom.
1361
However, since I want the buttons centered, I add one call before the buttons are added, and one call after.
1362
Very handy.


maincontainer.addObject("centercontainer","container")
centercontainer.layout = 2
centercontainer.autosize = 1
centercontainer.stylesheet="background-color:rgb(239,244,255)"
centercontainer.spacing = 10
centercontainer.padding = 10
centercontainer.margin = 10
centercontainer.addstretch()
centercontainer.addobject("button1","mybutton")
button1.caption = "Button One"
centercontainer.addobject("button2","mybutton")
button2.caption = "Button Two"
centercontainer.addstretch()


Herb