Python Reference Guide
 
Loading...
Searching...
No Matches
UI\TutorialGrid.py
1# Copyright 2009 Autodesk, Inc. All rights reserved.
2# Use of this software is subject to the terms of the Autodesk license agreement
3# provided at the time of installation or download, or which otherwise accompanies
4# this software in either electronic or hard copy form.
5#
6# Script description:
7# Tutorial for the FBGridLayout. This is the code used in the Python Scripting Help Dev Guide.
8#
9# Topic: FBGridLayout, FBMemo
10#
11
12from pyfbsdk import *
13import pyfbsdk_additions
14from pyfbsdk_additions import *
15
16t = FBCreateUniqueTool("Simple Grid Example")
17t.StartSizeX = 400
18t.StartSizeY = 400
19
20x = FBAddRegionParam(0,FBAttachType.kFBAttachLeft,"")
21y = FBAddRegionParam(0,FBAttachType.kFBAttachTop,"")
22w = FBAddRegionParam(0,FBAttachType.kFBAttachRight,"")
23h = FBAddRegionParam(0,FBAttachType.kFBAttachBottom,"")
24t.AddRegion("main","main", x, y, w, h)
25
26# create our gridLayout
27grid = FBGridLayout()
28t.SetControl("main", grid)
29
30#Create our Label
31
32label = FBLabel()
33label.Caption = "Enter your suggestions:"
34
35# add the label to the top left corner of the grid
36grid.Add(label, 0, 0)
37
38# create the Memo
39memo = FBMemo()
40
41# we want the memo to span from row 1 to row1 and from column 0 to column 2
42grid.AddRange(memo, 1, 1, 0, 2)
43
44# create buttons
45ok = FBButton()
46ok.Caption = "Ok"
47cancel = FBButton()
48cancel.Caption = "Cancel"
49
50# place the buttons in their respective columns and in row2
51grid.Add(ok, 2, 1)
52grid.Add(cancel, 2, 2)
53
54# now assign the rows and columns attributes
55
56# Fixed the height of row 0 and row 2 so the label and the buttons
57# have a normal height
58grid.SetRowHeight(0, 30)
59grid.SetRowHeight(2, 30)
60
61# want to fix the width of column 1 and 2 so the buttons are
62# of a normal size
63grid.SetColWidth( 1, 45 )
64grid.SetColWidth( 2, 45 )
65
66# To ensure our memo can be stretched, ensure row 1 and column 0 have a ratio
67grid.SetColRatio( 0, 1.0 )
68grid.SetRowRatio( 1, 1.0 )
69
70
71ShowTool(t)
Used to create and manage buttons in a user interface.
Definition: pyfbsdk_generated.h:2442
Text label.
Definition: pyfbsdk_generated.h:9829
Multi-line text input.
Definition: pyfbsdk_generated.h:10680