UI/RadioButton.py

UI/RadioButton.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 with radio buttons and show how to manage them with a FBButtonGroup.
8 #
9 # Topic: FBAttachType, FBButtonStyle, FBButton, FBButtonGroup
10 #
11 
12 from pyfbsdk import *
13 from pyfbsdk_additions import *
14 
15 def BtnRadioCallback(control, event):
16  print control.Caption, " has been clicked!"
17 
18 def PopulateLayout(mainLyt):
19  group = FBButtonGroup()
20  group.AddCallback(BtnRadioCallback)
21  anchor = ""
22  attachType = FBAttachType.kFBAttachTop
23 
24  for i in range(5):
25  name = "BtnRadio " + str(i)
26  b = FBButton()
27  group.Add(b)
28 
29  b.Caption = name
30  b.Style = FBButtonStyle.kFBRadioButton
31 
32  x = FBAddRegionParam(10,FBAttachType.kFBAttachLeft,"")
33  y = FBAddRegionParam(10,attachType,anchor)
34  w = FBAddRegionParam(100,FBAttachType.kFBAttachNone,"")
35  h = FBAddRegionParam(25,FBAttachType.kFBAttachNone,"")
36 
37  mainLyt.AddRegion(name,name, x, y, w, h)
38 
39  mainLyt.SetControl(name,b)
40 
41  attachType = FBAttachType.kFBAttachBottom
42  anchor = name
43 
44 def CreateTool():
45  # Tool creation will serve as the hub for all other controls
46  t = FBCreateUniqueTool("Radiobox Example")
47 
48  PopulateLayout(t)
49  ShowTool(t)
50 
51 
52 CreateTool()
53 
54 
55