Skip to content

Instantly share code, notes, and snippets.

@takowasabi
Created June 4, 2012 06:49
Show Gist options
  • Select an option

  • Save takowasabi/2866748 to your computer and use it in GitHub Desktop.

Select an option

Save takowasabi/2866748 to your computer and use it in GitHub Desktop.
motionbuilder GUI list
#MB2011
#なんの変哲もないVerticalListなんだけど、リストの値を上からlist mohi1,list mohi2,list mohi3...と複数選択していくと値が取得できず、
#下からlist mohi10,list mohi9,list mohi8って選択していくとその時選択した値が得られる・・・。
from pyfbsdk import *
from pyfbsdk_additions import *
def ListCallback(control, event):
for idx,item in enumerate(control.Items):
   if control.IsSelected(idx):
    print item, "has been selected!"
def PopulateLayout(mainLyt):
x = FBAddRegionParam(0,FBAttachType.kFBAttachLeft,"")
y = FBAddRegionParam(0,FBAttachType.kFBAttachTop,"")
w = FBAddRegionParam(200,FBAttachType.kFBAttachNone,"")
h = FBAddRegionParam(0,FBAttachType.kFBAttachBottom,"")
mainLyt.AddRegion("main","main", x,y,w,h)
lyt = VBoxLayout()
mainLyt.SetControl("main",lyt)
# List creation
global controls
controls = FBList()
controls.OnChange.Add(ListCallback)
# fill the list with dummy data
for i in range(10):
name = "list mohi %d" % (i + 1)
controls.Items.append(name)
controls.Style = FBListStyle.kFBVerticalList
lyt.Add(controls, 200)
controls.Selected(0,False)
controls.MultiSelect =True
def CreateTool():
t = CreateUniqueTool("List Example")
PopulateLayout(t)
ShowTool(t)
CreateTool()
#MB2011
#なんの変哲もないVerticalListなんだけど、リストの値を上からlist mohi1,list mohi2,list mohi3...と複数選択していくと値が取得できず、
#下からlist mohi10,list mohi9,list mohi8って選択していくとその時選択した値が得られる・・・。
from pyfbsdk import *
from pyfbsdk_additions import *
def ListCallback(control, event):
print control.Items[control.ItemIndex], "has been selected!"
def PopulateLayout(mainLyt):
x = FBAddRegionParam(0,FBAttachType.kFBAttachLeft,"")
y = FBAddRegionParam(0,FBAttachType.kFBAttachTop,"")
w = FBAddRegionParam(200,FBAttachType.kFBAttachNone,"")
h = FBAddRegionParam(0,FBAttachType.kFBAttachBottom,"")
mainLyt.AddRegion("main","main", x,y,w,h)
lyt = VBoxLayout()
mainLyt.SetControl("main",lyt)
# List creation
global controls
controls = FBList()
controls.OnChange.Add(ListCallback)
# fill the list with dummy data
for i in range(10):
name = "list mohi %d" % (i + 1)
controls.Items.append(name)
controls.Style = FBListStyle.kFBVerticalList
lyt.Add(controls, 200)
controls.Selected(0,False)
controls.MultiSelect =True
def CreateTool():
t = CreateUniqueTool("List Example")
PopulateLayout(t)
ShowTool(t)
CreateTool()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment