Python Reference Guide
 
Loading...
Searching...
No Matches
UI\List.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 2 different kinds of list and shows how to register callbacks.
8#
9# Topic: FBVBoxLayout, FBListStyle, FBList
10#
11
12from pyfbsdk import *
13from pyfbsdk_additions import *
14
15def ListCallback(control, event):
16 print(control.Items[control.ItemIndex], "has been selected!")
17
18
19def PopulateLayout(mainLyt):
20 x = FBAddRegionParam(0,FBAttachType.kFBAttachLeft,"")
21 y = FBAddRegionParam(0,FBAttachType.kFBAttachTop,"")
22 w = FBAddRegionParam(200,FBAttachType.kFBAttachNone,"")
23 h = FBAddRegionParam(0,FBAttachType.kFBAttachBottom,"")
24 mainLyt.AddRegion("main","main", x,y,w,h)
25
26 lyt = FBVBoxLayout()
27 mainLyt.SetControl("main",lyt)
28
29
30 # List creation
31 global controls
32 controls = [FBList(), FBList()]
33 for l in controls:
34 l.OnChange.Add(ListCallback)
35 # fill the list with dummy data
36 for i in range(10):
37 name = "list element %d" % (i + 1)
38 l.Items.append(name)
39
40
41 #FBListStyle.kFBDropDownList
42 #FBListStyle.kFBVerticalList
43 controls[0].Style = FBListStyle.kFBDropDownList
44 lyt.Add(controls[0], 25)
45 controls[0].Selected(4, True)
46
47 controls[1].Style = FBListStyle.kFBVerticalList
48 lyt.Add(controls[1], 200)
49 controls[1].Selected(7, True)
50 controls[1].MultiSelect = True
51
52
53def CreateTool():
54 # Tool creation will serve as the hub for all other controls
55 t = FBCreateUniqueTool("List Example")
56 PopulateLayout(t)
57 ShowTool(t)
58
59
60CreateTool()
List of items.
Definition: pyfbsdk_generated.h:10213