UI/ArrowButton.py

UI/ArrowButton.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 which shows the FBArrowButton and how to show/hide content
8 #
9 # Topic: FBArrowButton
10 #
11 
12 from pyfbsdk import *
13 from pyfbsdk_additions import *
14 
15 
16 def PopulateLayout(mainLyt):
17  anchor = FBAttachType.kFBAttachTop
18  anchorRegion = ""
19  for i in range(3):
20  lytName = "Border" + str(i)
21  lyt = FBLayout()
22  x = FBAddRegionParam(10,FBAttachType.kFBAttachLeft,"")
23  y = FBAddRegionParam(10,FBAttachType.kFBAttachTop,"")
24  w = FBAddRegionParam(200,FBAttachType.kFBAttachNone,"")
25  h = FBAddRegionParam(200,FBAttachType.kFBAttachNone,"")
26  lyt.AddRegion(lytName,lytName, x, y, w, h)
27  lyt.SetBorder(lytName,FBBorderStyle.kFBStandardBorder,True, True,1,0,90,0)
28 
29  arrowName = "ButtonArrow" + str(i)
30  x = FBAddRegionParam(10,FBAttachType.kFBAttachLeft,"")
31  y = FBAddRegionParam(10,anchor,anchorRegion)
32  w = FBAddRegionParam(0,FBAttachType.kFBAttachNone,"")
33  h = FBAddRegionParam(0,FBAttachType.kFBAttachNone,"")
34  mainLyt.AddRegion(arrowName ,arrowName , x, y, w, h)
35 
36  b = FBArrowButton()
37  mainLyt.SetControl(arrowName ,b)
38 
39  # important : we set the content AFTER having added the button arrow
40  # to its parent layout
41  b.SetContent( "A layout border" + str(i), lyt, 250, 250 )
42  anchor = FBAttachType.kFBAttachBottom
43  anchorRegion = arrowName
44 
45 
46  # dummy label to show the layout moves
47  x = FBAddRegionParam(10,FBAttachType.kFBAttachLeft,"")
48  y = FBAddRegionParam(10,FBAttachType.kFBAttachBottom,arrowName)
49  w = FBAddRegionParam(100,FBAttachType.kFBAttachNone,"")
50  h = FBAddRegionParam(25,FBAttachType.kFBAttachNone,"")
51 
52  l = FBLabel()
53  l.Caption = "Dummy label!"
54  mainLyt.AddRegion("DummyLabel","DummyLabel", x, y, w, h)
55  mainLyt.SetControl("DummyLabel", l)
56 
57 def CreateTool():
58  # Tool creation will serve as the hub for all other controls
59  t = FBCreateUniqueTool("Arrow Button Example")
60  PopulateLayout(t)
61  ShowTool(t)
62 
63 CreateTool()