# 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 GridLayout. This is the code used in the Python Scripting Help Dev Guide. # # Topic: GridLayout, FBMemo # from pyfbsdk import * import pyfbsdk_additions from pyfbsdk_additions import * t = CreateUniqueTool("Simple Grid Example") t.StartSizeX = 400 t.StartSizeY = 400 x = FBAddRegionParam(0,FBAttachType.kFBAttachLeft,"") y = FBAddRegionParam(0,FBAttachType.kFBAttachTop,"") w = FBAddRegionParam(0,FBAttachType.kFBAttachRight,"") h = FBAddRegionParam(0,FBAttachType.kFBAttachBottom,"") t.AddRegion("main","main", x, y, w, h) # create our gridLayout grid = GridLayout() t.SetControl("main", grid) #Create our Label label = FBLabel() label.Caption = "Enter your suggestions:" # add the label to the top left corner of the grid grid.Add(label, 0, 0) # create the Memo memo = FBMemo() # we want the memo to span from row 1 to row1 and from column 0 to column 2 grid.AddRange(memo, 1, 1, 0, 2) # create buttons ok = FBButton() ok.Caption = "Ok" cancel = FBButton() cancel.Caption = "Cancel" # place the buttons in their respective columns and in row2 grid.Add(ok, 2, 1) grid.Add(cancel, 2, 2) # now assign the rows and columns attributes # Fixed the height of row 0 and row 2 so the label and the buttons # have a normal height grid.SetRowHeight(0, 30) grid.SetRowHeight(2, 30) # want to fix the width of column 1 and 2 so the buttons are # of a normal size grid.SetColWidth( 1, 45 ) grid.SetColWidth( 2, 45 ) # To ensure our memo can be stretched, ensure row 1 and column 0 have a ratio grid.SetColRatio( 0, 1.0 ) grid.SetRowRatio( 1, 1.0 ) ShowTool(t)