Python Reference Guide
 
Loading...
Searching...
No Matches
UI\Layout.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 an empty layout (with border) and shows how to register clalback (idle, input, paint, resize, show)
8#
9# Topic: FBLayout
10#
11
12from pyfbsdk import *
13from pyfbsdk_additions import *
14
15def OnInputCb(control,event):
16 print("OnInput ", control, event.Key, event.X, event.Y)
17
18def OnResizeCb(control,event):
19 print("OnResize ", control, event.Width, event.Height)
20
21def OnShowCb(control,event):
22 print("OnShow ", control, event.Shown)
23
24def OnPaintCb(control,event):
25 print("OnPaint ", control, event)
26
27def OnIdleCb(control,event):
28 print("OnIdle ", control, event)
29
30def PopulateLayout(mainLyt):
31 lyt = FBLayout()
32 x = FBAddRegionParam(10,FBAttachType.kFBAttachLeft,"")
33 y = FBAddRegionParam(10,FBAttachType.kFBAttachTop,"")
34 w = FBAddRegionParam(400,FBAttachType.kFBAttachNone,"")
35 h = FBAddRegionParam(40,FBAttachType.kFBAttachNone,"")
36 lyt.AddRegion("Border1","Border2", x, y, w, h)
37 lyt.SetBorder("Border1",FBBorderStyle.kFBStandardBorder,True, True,1,0,90,0)
38
39 lyt.OnInput.Add(OnInputCb)
40 lyt.OnResize.Add(OnResizeCb)
41 lyt.OnShow.Add(OnShowCb)
42 # This is commented out because these callbacks run all the time
43 # lyt.OnPaint.Add(OnPaintCb)
44 # lyt.OnIdle.Add(OnIdleCb)
45
46 x = FBAddRegionParam(10,FBAttachType.kFBAttachLeft,"")
47 y = FBAddRegionParam(10,FBAttachType.kFBAttachTop,"")
48 w = FBAddRegionParam(-10,FBAttachType.kFBAttachRight,"")
49 h = FBAddRegionParam(-10,FBAttachType.kFBAttachBottom,"")
50 mainLyt.AddRegion("Reg","Reg", x, y, w, h)
51 mainLyt.SetControl("Reg",lyt)
52
53def CreateTool():
54 # Tool creation will serve as the hub for all other controls
55 t = FBCreateUniqueTool("Tool Layout")
56
57 PopulateLayout(t)
58 ShowTool(t)
59
60CreateTool()
61
Used to build the user interface.
Definition: pyfbsdk_generated.h:9906