Python Reference Guide
 
Loading...
Searching...
No Matches
UI\Button.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 that shows different kind of buttons and their properties.
8#
9# Topic: FBButton, FBButtonStyle, FBTextJustify, FBButtonLook
10#
11
12from pyfbsdk import *
13from pyfbsdk_additions import *
14
15# Button creation
16def BtnCallback(control, event):
17 print(control.Caption, " has been clicked!")
18
19def PopulateLayout(mainLyt):
20 x = FBAddRegionParam(0,FBAttachType.kFBAttachLeft,"")
21 y = FBAddRegionParam(0,FBAttachType.kFBAttachTop,"")
22 w = FBAddRegionParam(0,FBAttachType.kFBAttachRight,"")
23 h = FBAddRegionParam(25,FBAttachType.kFBAttachNone,"")
24 mainLyt.AddRegion("main","main", x, y, w, h)
25 lyt = FBHBoxLayout()
26 mainLyt.SetControl("main",lyt)
27
28 b = FBButton()
29 b.Caption = "But1"
30 b.Justify = FBTextJustify.kFBTextJustifyLeft
31 lyt.Add(b,60)
32 b.OnClick.Add(BtnCallback)
33
34 b = FBButton()
35 b.Caption = "But2"
36 b.Justify = FBTextJustify.kFBTextJustifyRight
37 lyt.Add(b,60)
38 b.OnClick.Add(BtnCallback)
39
40
41 b = FBButton()
42 b.Caption = "But3"
43 b.Style = FBButtonStyle.kFB2States
44 b.Look = FBButtonLook.kFBLookColorChange
45 b.Justify = FBTextJustify.kFBTextJustifyCenter
46 b.SetStateColor(FBButtonState.kFBButtonState0,FBColor(1.0, 0.0, 0.5))
47 b.SetStateColor(FBButtonState.kFBButtonState1,FBColor(0.0, 1.0, 0.5))
48 lyt.Add(b,60)
49
50 b.OnClick.Add(BtnCallback)
51
52 b = FBButton()
53 b.Caption = "But4"
54 b.Style = FBButtonStyle.kFBBitmap2States
55 b.Look = FBButtonLook.kFBLookNormal
56 b.Justify = FBTextJustify.kFBTextJustifyCenter
57 b.SetImageFileNames("tape/tape_play_off.png","tape/tape_play_on.png")
58 lyt.Add(b,60)
59
60 b.OnClick.Add(BtnCallback)
61
62 b = FBButton()
63 b.Caption = "Check1"
64 b.Style = FBButtonStyle.kFBCheckbox
65 b.Justify = FBTextJustify.kFBTextJustifyLeft
66 lyt.Add(b,60)
67
68 b.OnClick.Add(BtnCallback)
69
70
71 b = FBButton()
72 b.Caption = "Check2"
73 b.Style = FBButtonStyle.kFBCheckbox
74 b.Justify = FBTextJustify.kFBTextJustifyCenter
75 lyt.Add(b,60)
76 b.State = True
77
78
79 b.OnClick.Add(BtnCallback)
80
81def CreateTool():
82 # Tool creation will serve as the hub for all other controls
83 t = FBCreateUniqueTool("Button Example")
84 t.StartSizeX = 400
85 t.StartSizeY = 200
86 PopulateLayout(t)
87 ShowTool(t)
88
89
90CreateTool()
Used to create and manage buttons in a user interface.
Definition: pyfbsdk_generated.h:2442
Color vector.
Definition: pyfbsdk_generated.h:4470