MotionBuilder UI

Anybody familiar with the UI of MB? I want to achieve such an interface, as shown in the figure, I want to display two such formats in a UI window, I tried many methods but could not display two, I really do not know what to do, I hope to get help

Here’s my code:
from pyfbsdk import *
from pyfbsdk_additions import *

Normal Edit

def OnChange(control,event):
print control.Text

def PopulateLayout(mainLyt):
editStyles = [“FBEditVector”, “FBEditNumber”, “FBEditNumber”] # “FBEdit”,“FBEditColor”,“FBEditNumber”,“FBEditTimeCode”
edits = {}
anchor = “”
attachType = FBAttachType.kFBAttachTop

# Generically create different types of edit
for style in editStyles:
    # Create label
    labId = "Label" + style
    l = FBLabel()
    l.Caption = style
    x = FBAddRegionParam(10,FBAttachType.kFBAttachLeft,"")
    y = FBAddRegionParam(10,attachType,anchor)
    w = FBAddRegionParam(100,FBAttachType.kFBAttachNone,"")
    h = FBAddRegionParam(25,FBAttachType.kFBAttachNone,"")
    
    mainLyt.AddRegion(labId,labId, x, y, w, h)
    mainLyt.SetControl(labId,l)
        
    # Create edit
    editId = "Edit" + style
    initCall = "%s()" % (style)
    e = eval( initCall )
    edits[style] = e
    
    x = FBAddRegionParam(10,FBAttachType.kFBAttachRight,labId)
    y = FBAddRegionParam(10,attachType,anchor)
    w = FBAddRegionParam(200,FBAttachType.kFBAttachNone,"")
    h = FBAddRegionParam(25,FBAttachType.kFBAttachNone,"")

    mainLyt.AddRegion(editId,editId, x, y, w, h)

    mainLyt.SetControl(editId,e)
  
    attachType = FBAttachType.kFBAttachBottom
    anchor = labId
    
# Do specific edit initialization according to its type

# Vector Edit
e = edits['FBEditVector']
e.Value = FBVector3d(0.0, 0.0,0.0)

def CreateTool():
# Tool creation will serve as the hub for all other controls
t = FBCreateUniqueTool(“Edit Example”)
PopulateLayout(t)
ShowTool(t)

CreateTool()

Howdy; with the approach you’re using the problem is with your 'ID’s (labId, editId) in that they aren’t unique, so when you attempt to add them to via the AddRegion and SetControl calls you are overwriting the previously created item, so you could have tried to make any number of entries and you’d only ever get one.

Not sure if this is the best approach but adding some kind of unique identifier via an index during creation allowed me to generate any number of entries, the shortcoming to that being your initialization outside the creation loop would need to be revisited if for some reason you needed explicit/specific values per field

TL;DR

from pyfbsdk import *
from pyfbsdk_additions import *
# Normal Edit

def OnChange(control,event):
    print control.Text

def PopulateLayout(mainLyt):
    editStyles = ["FBEditVector", "FBEditVector", "FBEditVector", "FBEditVector", "FBEditNumber", "FBEditNumber"] # “FBEdit”,“FBEditColor”,“FBEditNumber”,“FBEditTimeCode”
    edits = {}
    anchor = ""
    attachType = FBAttachType.kFBAttachTop

    # Generically create different types of edit
    
    index = 0  # quick and dirty index for unique IDs
    
    for style in editStyles:
        # Create label
        labId = "Label{}{}".format(style, index)
        l = FBLabel()
        l.Caption = style
        x = FBAddRegionParam(10,FBAttachType.kFBAttachLeft,"")
        y = FBAddRegionParam(10,attachType,anchor)
        w = FBAddRegionParam(100,FBAttachType.kFBAttachNone,"")
        h = FBAddRegionParam(25,FBAttachType.kFBAttachNone,"")
        
        mainLyt.AddRegion(labId,labId, x, y, w, h)
        mainLyt.SetControl(labId,l)
            
        # Create edit
        editId = "Edit{}{}".format(style, index)
        initCall = "%s()" % (style)
        e = eval( initCall )
        edits[style] = e
        
        x = FBAddRegionParam(10,FBAttachType.kFBAttachRight,labId)
        y = FBAddRegionParam(10,attachType,anchor)
        w = FBAddRegionParam(200,FBAttachType.kFBAttachNone,"")
        h = FBAddRegionParam(25,FBAttachType.kFBAttachNone,"")
    
        mainLyt.AddRegion(editId, editId, x, y, w, h)
    
        mainLyt.SetControl(editId, e)
      
        attachType = FBAttachType.kFBAttachBottom
        anchor = labId
        index = index + 1
        
    # Do specific edit initialization according to its type
    
    # Vector Edit
    e = edits['FBEditVector']
    e.Value = FBVector3d(0.0, 0.0,0.0)

def CreateTool():
    # Tool creation will serve as the hub for all other controls
    t = FBCreateUniqueTool("Edit Example")
    PopulateLayout(t)
    ShowTool(t)

CreateTool()

image

Edit
running with that index idea you might run into a few issues trying to hook back into them, it was a pretty hacky solution that could probably be better addressed with a dictionary like

editStyles = {"myEditVector0": "FBEditVector", "myEditVectorN": "FBEditVector", "myEditNumber0": "FBEditNumber"}  # etc...

just as another option in case the index suffix names were going to cause confusion or problems down the line

Thank you very much for your reply. This is what I want. Thank you :咧着嘴笑: