UI/Attach.py

UI/Attach.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 # Create a tool that shows how to specify attach in a FBLayout
8 #
9 # Topic: FBAttachType, FBLayout
10 
11 from pyfbsdk import *
12 from pyfbsdk_additions import *
13 
14 
15 # Tool creation will serve as the hub for all other controls
16 t = FBCreateUniqueTool("Attach Example")
17 
18 b = FBButton()
19 b.Caption = "But"
20 
21 # Create a button that is left justify
22 x = FBAddRegionParam(0,FBAttachType.kFBAttachLeft,"")
23 # ... and at the top of the layout.
24 y = FBAddRegionParam(0,FBAttachType.kFBAttachTop,"")
25 # its width is fixed at 40 pixels
26 w = FBAddRegionParam(40,FBAttachType.kFBAttachNone,"")
27 # and its height is fixed at 40 pixels
28 h = FBAddRegionParam(40,FBAttachType.kFBAttachNone,"")
29 t.AddRegion("Btn","Btn", x, y, w, h)
30 t.SetControl("Btn",b)
31 
32 b2 = FBButton()
33 b2.Caption = "But2"
34 
35 # Create a button that is situated to the right of the region "Btn"
36 x1 = FBAddRegionParam(5,FBAttachType.kFBAttachRight,"Btn")
37 # attach to the top of the layout
38 y1 = FBAddRegionParam(0,FBAttachType.kFBAttachTop,"")
39 # its width is fixed at 40 pixels
40 w1 = FBAddRegionParam(40,FBAttachType.kFBAttachNone,"")
41 # and its height is fixed at 40 pixels
42 h1 = FBAddRegionParam(40,FBAttachType.kFBAttachNone,"")
43 t.AddRegion("Btn2","Btn2", x1, y1, w1, h1)
44 t.SetControl("Btn2",b2)
45 
46 b3 = FBButton()
47 b3.Caption = "But3"
48 
49 # Create a button that Right justify in the FBLayout.
50 # since the x Region param sets the left corner of the controls
51 # we need to offset the attach by -45 pixels so the button is shown.
52 x3 = FBAddRegionParam(-45,FBAttachType.kFBAttachRight,"")
53 y3 = FBAddRegionParam(0,FBAttachType.kFBAttachTop,"")
54 w3 = FBAddRegionParam(40,FBAttachType.kFBAttachNone,"")
55 h3 = FBAddRegionParam(40,FBAttachType.kFBAttachNone,"")
56 t.AddRegion("Btn3","Btn3", x3, y3, w3, h3)
57 t.SetControl("Btn3",b3)
58 
59 b4 = FBButton()
60 b4.Caption = "But4"
61 
62 # create a button that is situated at the left of region "Btn3".
63 # we need to offset it by -45 pixels so it doesn't overlap Btn3
64 x4 = FBAddRegionParam(-45,FBAttachType.kFBAttachLeft,"Btn3")
65 y4 = FBAddRegionParam(0,FBAttachType.kFBAttachTop,"")
66 w4 = FBAddRegionParam(40,FBAttachType.kFBAttachNone,"")
67 h4 = FBAddRegionParam(40,FBAttachType.kFBAttachNone,"")
68 t.AddRegion("Btn4","Btn4", x4, y4, w4, h4)
69 t.SetControl("Btn4",b4)
70 
71 ShowTool(t)