MotionBuilder Python Script21 - UI_Popup

合作

几天算是通了一遍导入流程,对动画系统以及引擎的操作都有了更深的理解,还是不错的

今天我们来看一下Popup

一、Popup

弹出框,可以自定义内容

我们先来看一下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 that will create and close a FBPopup
#
# Topic: FBButton, FBPopup
#

from pyfbsdk import *
from pyfbsdk_additions import *


# Button creation
def ShowPopupCallback(control, event):
    global t
    popup.Show(t)


# a Popup is really a layout. It should be populated/initialized
def ClosePopupCallback(control, event):
    popup.Close(True)


def PopulateLayout(mainLyt):
    # create a button on the tool that will show the popup
    b = FBButton()
    b.Caption = "Pop up"

    x = FBAddRegionParam(10, FBAttachType.kFBAttachLeft, "")
    y = FBAddRegionParam(10, FBAttachType.kFBAttachTop, "")
    w = FBAddRegionParam(50, FBAttachType.kFBAttachNone, "")
    h = FBAddRegionParam(25, FBAttachType.kFBAttachNone, "")

    mainLyt.AddRegion("Btn", "Btn", x, y, w, h)
    mainLyt.SetControl("Btn", b)

    b.OnClick.Add(ShowPopupCallback)

    # create the popup
    global popup
    popup = FBPopup()
    popup.Caption = "Popup"
    popup.Modal = False

    popup.Left = 300
    popup.Top = 300
    popup.Width = 400
    popup.Height = 500

    b = FBButton()
    b.Caption = "Close"
    b.OnClick.Add(ClosePopupCallback)

    popup.AddRegion("Close", "Close", x, y, w, h)
    popup.SetControl("Close", b)


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


CreateTool()

decomposition and refactor!

二、结语

继续!

共勉!

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

推荐阅读更多精彩内容