The Night Knight
今天学习了一部分导入流程,写完这篇就整理整理
今天我们来看一下UI中最常用的控件 Label
一、Label
标签,可以用于显示文本和图片
我们先来看一下UI效果
UI效果
这里展示了多种Label的显示形式,之后我会再研究一下能否用于显示图片(当然可以直接用ImageContainer)
来看一下代码
#!/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 labels and set all their properties.
#
# Topic: FBLabel, FBTextJustify, FBTextStyle
#
from pyfbsdk import *
from pyfbsdk_additions import *
def PopulateLayout(mainLyt):
lyt = FBVBoxLayout()
x = FBAddRegionParam(0, FBAttachType.kFBAttachLeft, "")
y = FBAddRegionParam(0, FBAttachType.kFBAttachTop, "")
w = FBAddRegionParam(50, FBAttachType.kFBAttachNone, "")
h = FBAddRegionParam(0, FBAttachType.kFBAttachBottom, "")
mainLyt.AddRegion("main", "main", x, y, w, h)
mainLyt.SetControl("main", lyt);
l = FBLabel()
l.Caption = "This is a label!!!!"
l.Style = FBTextStyle.kFBTextStyleBold
l.WordWrap = True
lyt.Add(l, 25)
# FBTextJustify.kFBTextJustifyLeft
# FBTextJustify.kFBTextJustifyRight
# FBTextJustify.kFBTextJustifyCenter
# FBTextStyle.kFBTextStyleNone
# FBTextStyle.kFBTextStyleBold
# FBTextStyle.kFBTextStyleItalic
# FBTextStyle.kFBTextStyleUnderlined
l = FBLabel()
l.Caption = "left"
l.Style = FBTextStyle.kFBTextStyleItalic
l.Justify = FBTextJustify.kFBTextJustifyLeft
lyt.Add(l, 25)
l = FBLabel()
l.Caption = "center"
l.Style = FBTextStyle.kFBTextStyleUnderlined
l.Justify = FBTextJustify.kFBTextJustifyCenter
lyt.Add(l, 25)
l = FBLabel()
l.Caption = "right"
l.Justify = FBTextJustify.kFBTextJustifyRight
lyt.Add(l, 25)
def CreateTool():
# Tool creation will serve as the hub for all other controls
t = FBCreateUniqueTool("Label Example")
t.StartSizeX = 400
t.StartSizeY = 400
PopulateLayout(t)
ShowTool(t)
CreateTool()
代码清晰,decomposition and refactor!
二、结语
有什么问题可以留言
继续!
共勉!