|
Hello Everyone,
I’m trying to ‘get’ user entered values from a UI. I’ve looked through the MB help examples and have been investigating this for days now.
The only way I’ve seen this done is by declaring items as global objects. I used to script in MEL and typically avoided too many global declarations, is there a local way to read the FBEdit(), or is declaring globally the recommended workflow for python in MotionBuilder?
I have an example UI here, type in the field above and click the button…
def populateToolbox(ui):
al = FBAddRegionParam(0,FBAttachType.kFBAttachLeft,"")
at = FBAddRegionParam(0,FBAttachType.kFBAttachTop,"")
ar = FBAddRegionParam(0,FBAttachType.kFBAttachRight,"")
an = FBAddRegionParam(200,FBAttachType.kFBAttachNone,"")
ui.AddRegion("main","main", al, at, ar, an)
mainLyt = VBoxLayout()
ui.SetControl("main",mainLyt)
global effectorField
effectorField = FBEdit()
effectorField.Caption = 'Layer Mode'
mainLyt.Add(effectorField,50)
b1 = FBButton()
b1.Caption = 'Print Text Above'
b1.OnClick.Add(doIt)
mainLyt.Add(b1, 25)
def doIt(control, event):
print effectorField.Text
def newUI():
ui = CreateUniqueTool('Test UI')
ui.StartSizeX = 200
ui.StartSizeY = 120
populateToolbox(ui)
ShowTool(ui)
newUI()
Any help appreciated,
Steve.
|