# Copyright 2009 Autodesk, Inc. All rights reserved. # Use of this software is subject to the terms of the Autodesk license agreement # provided at the time of installation or download, or which otherwise accompanies # this software in either electronic or hard copy form. # # Script description: # Tutorial for the BoxLayout. This is the code used in the Python Scripting Help Dev Guide. # # Topic: FBMemo, VBoxLayout, FBContainer # from pyfbsdk import * from pyfbsdk_additions import * t = CreateUniqueTool("Vertical sample") t.StartSizeX = 400 t.StartSizeY = 400 # Create region to hold our vbox. the vbox will fill the whole region x = FBAddRegionParam(0,FBAttachType.kFBAttachLeft,"") y = FBAddRegionParam(0,FBAttachType.kFBAttachTop,"") w = FBAddRegionParam(0,FBAttachType.kFBAttachRight,"") h = FBAddRegionParam(0,FBAttachType.kFBAttachBottom,"") t.AddRegion("vbox","vbox", x, y, w, h) # create our vbox: we set the inital kFBAttachTop so controls are # lined from top to bottom vbox = VBoxLayout( FBAttachType.kFBAttachTop ) t.SetControl("vbox",vbox) # create the Label label = FBLabel() label.Caption = "Here is our test label" # add the label and specify a fixed height of 30 pixels vbox.Add(label, 30) # create the container container = FBContainer() # specify a ratio of 2 vbox.AddRelative(container, 2.0) # create the memo memo = FBMemo() # specify a ratio of 1 vbox.AddRelative(memo, 1.0) # ratio explanation # the ratio total is 2.0 + 1.0 = 3.0 # the container occuppies 2.0/3.0 : hence 2/3 of the total space # the memo occupies 1.0/3.0 : hence 1/3 of space # we could have used 0.66 and 0.33 as ratio and the result would have # been the same ShowTool(t)