MotionBuilder Python Script23 - UI_RadioButton

差点彻底断掉

自从3月份更新了一篇之后就又断掉了,对于现在的UI例子文档只不过是录个gif再贴上官方代码,非常简单的事竟然会持续断更,罪过罪过...

之后尽量把这套example的代码贴完!

一、RadioButton

单选按钮控件

先看一下UI效果


Radiobox Example.gif

再看一下效果实现的代码

# 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 radio buttons and show how to manage them with a FBButtonGroup.
#
# Topic: FBAttachType, FBButtonStyle, FBButton, FBButtonGroup
#

from pyfbsdk import *
from pyfbsdk_additions import *

def BtnRadioCallback(control, event):
    print control.Caption, " has been clicked!"

def PopulateLayout(mainLyt):
    group = FBButtonGroup()
    group.AddCallback(BtnRadioCallback)
    anchor = ""
    attachType = FBAttachType.kFBAttachTop
    
    for i in range(5):
        name = "BtnRadio " + str(i)
        b = FBButton()
        group.Add(b)
        
        b.Caption = name
        b.Style = FBButtonStyle.kFBRadioButton
    
        x = FBAddRegionParam(10,FBAttachType.kFBAttachLeft,"")
        y = FBAddRegionParam(10,attachType,anchor)
        w = FBAddRegionParam(100,FBAttachType.kFBAttachNone,"")
        h = FBAddRegionParam(25,FBAttachType.kFBAttachNone,"")
    
        mainLyt.AddRegion(name,name, x, y, w, h)
    
        mainLyt.SetControl(name,b)
                
        attachType = FBAttachType.kFBAttachBottom
        anchor = name

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


CreateTool()

二、结语

有问题可以留言~

共勉!

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容