UI/Slider.py

UI/Slider.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 slider and shows how to hook to its value change callback
8 #
9 # Topic: FBSlider,FBOrientation
10 #
11 
12 from pyfbsdk import *
13 from pyfbsdk_additions import *
14 
15 def ValueChange(control,event):
16  print control.Value
17 
18 def Transaction(control,event):
19  print "Transaction, is begin: ", event.IsBeginTransaction
20 
21 
22 def PopulateLayout(mainLyt):
23  x = FBAddRegionParam(0,FBAttachType.kFBAttachLeft,"")
24  y = FBAddRegionParam(0,FBAttachType.kFBAttachTop,"")
25  w = FBAddRegionParam(0,FBAttachType.kFBAttachRight,"")
26  h = FBAddRegionParam(0,FBAttachType.kFBAttachBottom,"")
27  mainLyt.AddRegion("main","main", x, y, w, h)
28 
29  lyt = FBHBoxLayout()
30  mainLyt.SetControl('main', lyt)
31 
32  hs = FBSlider()
33  hs.Orientation = FBOrientation.kFBHorizontal
34  hs.SmallStep = 10
35  hs.LargeStep = 10
36  hs.OnChange.Add(ValueChange)
37  hs.OnTransaction.Add(Transaction)
38  lyt.Add(hs, 150, height=25)
39 
40  vs = FBSlider()
41  vs.Orientation = FBOrientation.kFBVertical
42  lyt.Add(vs, 25, height=150)
43 
44 
45 def CreateTool():
46  # Tool creation will serve as the hub for all other controls
47  t = FBCreateUniqueTool("Slider Example")
48  t.StartSizeX = 400
49  t.StartSizeY = 400
50 
51 
52  PopulateLayout(t)
53  ShowTool(t)
54 
55 
56 CreateTool()
57