美文网首页工具癖程序员
MotionBuilder Python Script19 -

MotionBuilder Python Script19 -

作者: Houdinini | 来源:发表于2019-08-13 20:30 被阅读3次
    We are
    今天重新尝试构建了部分流程,看了一集海昏侯,挺好看

    今天我们来看一下也是UI中非常常用的List

    一、List

    列表,以及下拉列表

    我们来看一下UI效果

    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 a tool with an empty layout (with border) and shows how to register clalback (idle, input, paint, resize, show)
    #
    # Topic: FBLayout
    #
    
    from pyfbsdk import *
    from pyfbsdk_additions import *
    
    
    def OnInputCb(control, event):
        print "OnInput ", control, event.Key, event.X, event.Y
    
    
    def OnResizeCb(control, event):
        print "OnResize ", control, event.Width, event.Height
    
    
    def OnShowCb(control, event):
        print "OnShow ", control, event.Shown
    
    
    def OnPaintCb(control, event):
        print "OnPaint ", control, event
    
    
    def OnIdleCb(control, event):
        print "OnIdle ", control, event
    
    
    def PopulateLayout(mainLyt):
        lyt = FBLayout()
        x = FBAddRegionParam(10, FBAttachType.kFBAttachLeft, "")
        y = FBAddRegionParam(10, FBAttachType.kFBAttachTop, "")
        w = FBAddRegionParam(400, FBAttachType.kFBAttachNone, "")
        h = FBAddRegionParam(40, FBAttachType.kFBAttachNone, "")
        lyt.AddRegion("Border1", "Border2", x, y, w, h)
        lyt.SetBorder("Border1", FBBorderStyle.kFBStandardBorder, True, True, 1, 0, 90, 0)
    
        lyt.OnInput.Add(OnInputCb)
        lyt.OnResize.Add(OnResizeCb)
        lyt.OnShow.Add(OnShowCb)
        # This is commented out because these callbacks run all the time
        # lyt.OnPaint.Add(OnPaintCb)
        # lyt.OnIdle.Add(OnIdleCb)
    
        x = FBAddRegionParam(10, FBAttachType.kFBAttachLeft, "")
        y = FBAddRegionParam(10, FBAttachType.kFBAttachTop, "")
        w = FBAddRegionParam(-10, FBAttachType.kFBAttachRight, "")
        h = FBAddRegionParam(-10, FBAttachType.kFBAttachBottom, "")
        mainLyt.AddRegion("Reg", "Reg", x, y, w, h)
        mainLyt.SetControl("Reg", lyt)
    
    
    def CreateTool():
        # Tool creation will serve as the hub for all other controls
        t = FBCreateUniqueTool("Tool Layout")
    
        PopulateLayout(t)
        ShowTool(t)
    
    
    CreateTool()
    

    大家仔细研究一下代码上方的几个函数,敲一敲,decomposition and refactor!

    二、结语

    有什么问题可以留言!

    共勉!

    相关文章

      网友评论

        本文标题:MotionBuilder Python Script19 -

        本文链接:https://www.haomeiwen.com/subject/aocijctx.html