from pyfbsdk import *
from pyfbsdk_additions import *
def BtnCallback(control, event):
print control.Caption, " has been clicked!"
def PopulateLayout(mainLyt):
x = FBAddRegionParam(0,FBAttachType.kFBAttachLeft,"")
y = FBAddRegionParam(0,FBAttachType.kFBAttachTop,"")
w = FBAddRegionParam(0,FBAttachType.kFBAttachRight,"")
h = FBAddRegionParam(25,FBAttachType.kFBAttachNone,"")
mainLyt.AddRegion("main","main", x, y, w, h)
lyt = HBoxLayout()
mainLyt.SetControl("main",lyt)
b = FBButton()
b.Caption = "But1"
b.Justify = FBTextJustify.kFBTextJustifyLeft
lyt.Add(b,60)
b.OnClick.Add(BtnCallback)
b = FBButton()
b.Caption = "But2"
b.Justify = FBTextJustify.kFBTextJustifyRight
lyt.Add(b,60)
b.OnClick.Add(BtnCallback)
b = FBButton()
b.Caption = "But3"
b.Style = FBButtonStyle.kFB2States
b.Look = FBButtonLook.kFBLookColorChange
b.Justify = FBTextJustify.kFBTextJustifyCenter
b.SetStateColor(FBButtonState.kFBButtonState0,FBColor(1.0, 0.0, 0.5))
b.SetStateColor(FBButtonState.kFBButtonState1,FBColor(0.0, 1.0, 0.5))
lyt.Add(b,60)
b.OnClick.Add(BtnCallback)
b = FBButton()
b.Caption = "But4"
b.Style = FBButtonStyle.kFBBitmap2States
b.Look = FBButtonLook.kFBLookNormal
b.Justify = FBTextJustify.kFBTextJustifyCenter
b.SetImageFileNames("tape/tape_play_off.tif","tape/tape_play_on.tif")
lyt.Add(b,60)
b.OnClick.Add(BtnCallback)
b = FBButton()
b.Caption = "Check1"
b.Style = FBButtonStyle.kFBCheckbox
b.Justify = FBTextJustify.kFBTextJustifyLeft
lyt.Add(b,60)
b.OnClick.Add(BtnCallback)
b = FBButton()
b.Caption = "Check2"
b.Style = FBButtonStyle.kFBCheckbox
b.Justify = FBTextJustify.kFBTextJustifyCenter
lyt.Add(b,60)
b.State = True
b.OnClick.Add(BtnCallback)
def CreateTool():
t = CreateUniqueTool("Button Example")
t.StartSizeX = 400
t.StartSizeY = 200
PopulateLayout(t)
ShowTool(t)
CreateTool()