UI/TutorialBox.py
Main Page
Groups
Classes
Examples
UI/TutorialBox.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 FBBoxLayout. This is the code used in the Python Scripting Help Dev Guide.
8
#
9
# Topic: FBMemo, FBVBoxLayout, FBVisualContainer
10
#
11
12
from
pyfbsdk
import
*
13
from
pyfbsdk_additions
import
*
14
15
t =
FBCreateUniqueTool
(
"Vertical sample"
)
16
t.StartSizeX = 400
17
t.StartSizeY = 400
18
19
# Create region to hold our vbox. the vbox will fill the whole region
20
x =
FBAddRegionParam
(0,FBAttachType.kFBAttachLeft,
""
)
21
y =
FBAddRegionParam
(0,FBAttachType.kFBAttachTop,
""
)
22
w =
FBAddRegionParam
(0,FBAttachType.kFBAttachRight,
""
)
23
h =
FBAddRegionParam
(0,FBAttachType.kFBAttachBottom,
""
)
24
t.AddRegion(
"vbox"
,
"vbox"
, x, y, w, h)
25
26
# create our vbox: we set the inital kFBAttachTop so controls are
27
# lined from top to bottom
28
vbox =
FBVBoxLayout
( FBAttachType.kFBAttachTop )
29
t.SetControl(
"vbox"
,vbox)
30
31
# create the Label
32
label =
FBLabel
()
33
label.Caption =
"Here is our test label"
34
# add the label and specify a fixed height of 30 pixels
35
vbox.Add(label, 30)
36
37
# create the container
38
container =
FBVisualContainer
()
39
40
# specify a ratio of 2
41
vbox.AddRelative(container, 2.0)
42
43
# create the memo
44
memo =
FBMemo
()
45
46
# specify a ratio of 1
47
vbox.AddRelative(memo, 1.0)
48
49
# ratio explanation
50
# the ratio total is 2.0 + 1.0 = 3.0
51
# the container occuppies 2.0/3.0 : hence 2/3 of the total space
52
# the memo occupies 1.0/3.0 : hence 1/3 of space
53
# we could have used 0.66 and 0.33 as ratio and the result would have
54
# been the same
55
56
57
ShowTool
(t)