Python Reference Guide
 
Loading...
Searching...
No Matches
UI\Tree.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 a FBTree and modify its properties
8#
9# Topic: FBTree
10#
11
12from pyfbsdk import *
13from pyfbsdk_additions import *
14
15# Callback
16def TreeSelectCallback(control, event):
17 print("Node : ",event.TreeNode.Name, " selected.")
18
19def TreeCheckCallback(control, event):
20 print("Node : ",event.TreeNode.Name, " checked.")
21
22def 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
30 t = FBTree()
31 t.CheckBoxes = True
32 t.AutoExpandOnDblClick = True
33 t.AutoExpandOnDragOver = True
34 t.AutoScroll = True
35 t.AutoScrollOnExpand = True
36 t.ItemHeight = 40
37 t.DeselectOnCollapse = True
38 t.EditNodeOn2Select = True
39 t.HighlightOnRightClick = True
40 t.MultiDrag = True
41 t.MultiSelect = True
42 t.NoSelectOnDrag = True
43 t.NoSelectOnRightClick = False
44 t.ShowLines = True
45
46 mainLyt.SetControl("main",t)
47
48 r = t.GetRoot()
49 n = t.InsertLast(r, "1")
50 n.Checked = False
51 n = t.InsertLast(n, "2")
52 n = t.InsertLast(n, "3")
53 n = t.InsertLast(n, "4")
54 n.Checked = False
55 n = t.InsertLast(r, "5")
56 n = t.InsertLast(n, "6")
57 t.InsertLast(n, "7")
58
59 t.OnSelect.Add(TreeSelectCallback)
60 t.OnClickCheck.Add(TreeCheckCallback)
61
62def CreateTool():
63 # Tool creation will serve as the hub for all other controls
64 t = FBCreateUniqueTool("Tree Tool Example")
65 t.StartSizeX = 400
66 t.StartSizeY = 400
67 PopulateLayout(t)
68 ShowTool(t)
69
70CreateTool()
Tree list view.
Definition: pyfbsdk_generated.h:20413