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, preshow, 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 OnPreShowCb(control,event):
22 print("OnPreShow ", control, event.Show)
23
24def OnShowCb(control,event):
25 print("OnShow ", control, event.Shown)
26
27def OnPaintCb(control,event):
28 print("OnPaint ", control, event)
29
30def OnIdleCb(control,event):
31 print("OnIdle ", control, event)
32
33def PopulateLayout(mainLyt):
34 lyt = FBLayout()
35 x = FBAddRegionParam(10,FBAttachType.kFBAttachLeft,"")
36 y = FBAddRegionParam(10,FBAttachType.kFBAttachTop,"")
37 w = FBAddRegionParam(400,FBAttachType.kFBAttachNone,"")
38 h = FBAddRegionParam(40,FBAttachType.kFBAttachNone,"")
39 lyt.AddRegion("Border1","Border2", x, y, w, h)
40 lyt.SetBorder("Border1",FBBorderStyle.kFBStandardBorder,True, True,1,0,90,0)
41
42 lyt.OnInput.Add(OnInputCb)
43 lyt.OnResize.Add(OnResizeCb)
44 lyt.OnPreShow.Add(OnPreShowCb)
45 lyt.OnShow.Add(OnShowCb)
46 # This is commented out because these callbacks run all the time
47 # lyt.OnPaint.Add(OnPaintCb)
48 # lyt.OnIdle.Add(OnIdleCb)
49
50 x = FBAddRegionParam(10,FBAttachType.kFBAttachLeft,"")
51 y = FBAddRegionParam(10,FBAttachType.kFBAttachTop,"")
52 w = FBAddRegionParam(-10,FBAttachType.kFBAttachRight,"")
53 h = FBAddRegionParam(-10,FBAttachType.kFBAttachBottom,"")
54 mainLyt.AddRegion("Reg","Reg", x, y, w, h)
55 mainLyt.SetControl("Reg",lyt)
56
57def CreateTool():
58 # Tool creation will serve as the hub for all other controls
59 t = FBCreateUniqueTool("Tool Layout")
60
61 PopulateLayout(t)
62 ShowTool(t)
63
64CreateTool()
65
Used to build the user interface.
Definition: pyfbsdk_generated.h:9959