Results 1 to 1 of 1

Thread: Addstretch() function to help custom layouts

  1. #1

    Addstretch() function to help custom layouts

    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.
    Name:  adstretch1.png
Views: 379
Size:  4.1 KB

    If I add centercontainer.addstretch() before I add the buttons, it acts like a container and pushes the buttons to the bottom.
    Name:  adstretch2.png
Views: 310
Size:  3.7 KB
    However, since I want the buttons centered, I add one call before the buttons are added, and one call after.
    Name:  adstretch3.png
Views: 299
Size:  3.7 KB
    Very handy.
    Code:
    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
    Last edited by hmischel@diligentsystems.com; 2016-08-25 at 20:07.

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Journey into the Cloud
Join us