Python Reference Guide
 
Loading...
Searching...
No Matches
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
11from pyfbsdk import *
12from pyfbsdk_additions import *
13
14
15# Tool creation will serve as the hub for all other controls
16t = FBCreateUniqueTool("Attach Example")
17
18b = FBButton()
19b.Caption = "But"
20
21# Create a button that is left justify
22x = FBAddRegionParam(0,FBAttachType.kFBAttachLeft,"")
23# ... and at the top of the layout.
24y = FBAddRegionParam(0,FBAttachType.kFBAttachTop,"")
25# its width is fixed at 40 pixels
26w = FBAddRegionParam(40,FBAttachType.kFBAttachNone,"")
27# and its height is fixed at 40 pixels
28h = FBAddRegionParam(40,FBAttachType.kFBAttachNone,"")
29t.AddRegion("Btn","Btn", x, y, w, h)
30t.SetControl("Btn",b)
31
32b2 = FBButton()
33b2.Caption = "But2"
34
35# Create a button that is situated to the right of the region "Btn"
36x1 = FBAddRegionParam(5,FBAttachType.kFBAttachRight,"Btn")
37# attach to the top of the layout
38y1 = FBAddRegionParam(0,FBAttachType.kFBAttachTop,"")
39# its width is fixed at 40 pixels
40w1 = FBAddRegionParam(40,FBAttachType.kFBAttachNone,"")
41# and its height is fixed at 40 pixels
42h1 = FBAddRegionParam(40,FBAttachType.kFBAttachNone,"")
43t.AddRegion("Btn2","Btn2", x1, y1, w1, h1)
44t.SetControl("Btn2",b2)
45
46b3 = FBButton()
47b3.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.
52x3 = FBAddRegionParam(-45,FBAttachType.kFBAttachRight,"")
53y3 = FBAddRegionParam(0,FBAttachType.kFBAttachTop,"")
54w3 = FBAddRegionParam(40,FBAttachType.kFBAttachNone,"")
55h3 = FBAddRegionParam(40,FBAttachType.kFBAttachNone,"")
56t.AddRegion("Btn3","Btn3", x3, y3, w3, h3)
57t.SetControl("Btn3",b3)
58
59b4 = FBButton()
60b4.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
64x4 = FBAddRegionParam(-45,FBAttachType.kFBAttachLeft,"Btn3")
65y4 = FBAddRegionParam(0,FBAttachType.kFBAttachTop,"")
66w4 = FBAddRegionParam(40,FBAttachType.kFBAttachNone,"")
67h4 = FBAddRegionParam(40,FBAttachType.kFBAttachNone,"")
68t.AddRegion("Btn4","Btn4", x4, y4, w4, h4)
69t.SetControl("Btn4",b4)
70
71ShowTool(t)
Used to create and manage buttons in a user interface.
Definition: pyfbsdk_generated.h:2442