美文网首页工具癖
MotionBuilder Python Script16 -

MotionBuilder Python Script16 -

作者: Houdinini | 来源:发表于2019-08-08 19:54 被阅读25次
    自我检讨

    还是托更了,前两天专注于新家打扫,之后又重新接到了一些耗时的任务,不知不觉竟然将近5天没有更新,还是没有把小事做好!自我检讨!

    今天我们来看一下Motion中的GridLayout

    一、GridLayout

    网格布局,将控件以表格形式布局

    我们先来看一下UI效果


    GridLayout

    这里的控件都用Button来代替,大家可以尝试用之前文章中的控件来摆一摆!代码如下:

    from pyfbsdk import *
    from pyfbsdk_additions import *
    
    def PopulateLayout(mainLyt):
        # Create Main region frame:
        x = FBAddRegionParam(5,FBAttachType.kFBAttachLeft,"")
        y = FBAddRegionParam(5,FBAttachType.kFBAttachTop,"")
        w = FBAddRegionParam(-5,FBAttachType.kFBAttachRight,"")
        h = FBAddRegionParam(-5,FBAttachType.kFBAttachBottom,"")
        mainLyt.AddRegion("main","main", x, y, w, h)
    
        grid = FBGridLayout()
    
        grid.SetRowRatio(0, 3.0)
    
        # Add buttons in the first row
        for i in range(7):
            b = FBButton()
            b.Caption = "0," + str(i)
            grid.Add(b,0,i)
            
        # add buttons in the first column
        for i in range(7):
            b = FBButton()
            b.Caption = str(i) + ",0"
            grid.Add(b,i,0)
        
        b = FBButton()
        b.Caption = "0,1"
        grid.Add(b,0,1)    
            
        b = FBButton()
        b.Caption = "1,3"
        # specify button width: this will make the rows and columns grow to accomodate this big button
        grid.Add(b,1,3, width = 200)
            
        # set the height of the row 2
        grid.SetRowHeight(2, 50)
        
        b = FBButton()
        b.Caption = "2,2"
        # specify the width and height of a button
        grid.Add(b,2,2,width = 45, height = 25)
        
        # set the spacing between col3 and col4
        grid.SetColSpacing(3, 50)
        
        b = FBButton()
        b.Caption = "2,3"
        # specify that the button will be "right justified" in the column (attachX relates to horizontal position)
        grid.Add(b,2,3,attachX = FBAttachType.kFBAttachRight, width = 25, height = 20, attachY = FBAttachType.kFBAttachBottom)
    
        b = FBButton()
        b.Caption = "3,1"
        # specify the height of the button
        grid.Add(b,3,1, height = 200)
    
    
        b = FBButton()
        b.Caption = "3,2"
        # specify that the button will be attach to the bottom of the row (attachY relates to vertical position)
        grid.Add(b,3,2,attachY = FBAttachType.kFBAttachBottom, height = 25)
        
        b = FBButton()
        b.Caption = "3,6,3,6"
        # this button will span from row 3 to row 6 and from col 3 to col 6.
        grid.AddRange(b,3,6, 3, 6)
    
        mainLyt.SetControl("main",grid)
    
    def CreateTool():    
        # Tool creation will serve as the hub for all other controls
        t = FBCreateUniqueTool("Grid Example")
        PopulateLayout(t)
        # Button creation
        t.StartSizeX = 800
        t.StartSizeY = 800
        ShowTool(t)
    CreateTool()
    

    decomposition and refactor!

    二、结语

    做任何事情都要坚持!

    尤其是小事,一屋不扫何以扫天下!

    有什么问题可以留言!

    共勉!

    相关文章

      网友评论

        本文标题:MotionBuilder Python Script16 -

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