- MotionBuilder Python Script09 -
- MotionBuilder Python Tools - Ren
- MotionBuilder Python Script18 -
- MotionBuilder Python Script17 -
- MotionBuilder Python Script08 -
- MotionBuilder Python Script11 -
- MotionBuilder Python Script10 -
- MotionBuilder Python Script14 -
- MotionBuilder Python Script13 -
- MotionBuilder Python Script12 -

最近发现了咪咕音乐可以听周杰伦的歌
我们再来看一下MoBu中的Container的实现,与之前的BoxLayout 并不是一样的,我们来看一下
一、Container
Container 即容器,可以容纳许多小模块
先来看一下UI效果

官方这里展示了所有的图标模块形式,官方文档代码如下:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright 2009 Autodesk, Inc. All rights reserved.
# Use of this software is subject to the terms of the Autodesk license agreement
# provided at the time of installation or download, or which otherwise accompanies
# this software in either electronic or hard copy form.
#
# Script description:
# Create tool with a container and shows how to set icon in it.
# Shows how to register callback (double click, onChange, DragAndDrop) in the container.
#
# Topic: FBVisualContainer, FBOrientation
#
from pyfbsdk import *
from pyfbsdk_additions import *
def OnChangeCallback(control, event):
print control.GetSelection()
def OnDoubleClickCallback(control, event):
print control.GetSelection()
def OnDragAndDropCallback(control, event):
print event.State, event.PosX, event.PosY, event.Data[0], event.Data[1], event.Components
def PopulateLayout(mainLyt):
x = FBAddRegionParam(0, FBAttachType.kFBAttachLeft, "")
y = FBAddRegionParam(0, FBAttachType.kFBAttachTop, "")
w = FBAddRegionParam(0, FBAttachType.kFBAttachRight, "")
h = FBAddRegionParam(0, FBAttachType.kFBAttachBottom, "")
mainLyt.AddRegion("main", "main", x, y, w, h)
lyt = FBHBoxLayout()
mainLyt.SetControl("main", lyt)
icons = ["devices_body.png", "devices_generalpurp.png", "devices_gloves.png", "devices_joystick.png",
"devices_keyboard.png", "devices_mouse.png"]
containers = [FBVisualContainer(), FBVisualContainer()]
for containerIndex, c in enumerate(containers):
for i, icon in enumerate(icons):
itemIndex = ((containerIndex * 7) + i);
c.Items.append(("Item %d" % itemIndex, itemIndex))
c.ItemIconSet(itemIndex, icon)
c.ItemHeight = 70
c.ItemWidth = 70
c.OnDblClick.Add(OnDoubleClickCallback)
c.OnChange.Add(OnChangeCallback)
c.OnDragAndDrop.Add(OnDragAndDropCallback)
lyt.AddRelative(c)
containers[0].Orientation = FBOrientation.kFBHorizontal
containers[1].Orientation = FBOrientation.kFBVertical
def CreateTool():
# Tool creation will serve as the hub for all other controls
t = FBCreateUniqueTool("Container Tool Example")
t.StartSizeX = 400
t.StartSizeY = 400
PopulateLayout(t)
ShowTool(t)
CreateTool()
需要注意一下其中的Containers的方法操作,认真敲一敲(瞧一瞧),decomposition and refactor!
二、结语
有什么问题可以留言
继续!
共勉!
网友评论