zoukankan      html  css  js  c++  java
  • Blender之UILayout

    目标

    • [x] 总结Blender面板布局

    总结

    Blender面板中界面组件是通过UILayout进行组织的. 其主要属性如下:

    • row() 定义横向子布局.
    • column() 定义竖向子布局.
    • split() 按比例拆分行
    • column_flow() 定义多列的竖向子布局(根据列,计算行数, 然后按逐列摆放组件)
    • box() 定义有外框的竖向子布局
    • menu_pie() 饼状菜单
    • operator() 放置调用操作器的按钮
    • prop() 展示RNA,并把它放在布局中
    • label() 显示标签
    • separator() 分隔元素

    代码示例

    class SimplePanel(bpy.types.Panel):
        bl_space_type = 'VIEW_3D'
        bl_region_type = "TOOLS"
        bl_category = "Test"
        bl_label = "测试工具"
        bl_context = "objectmode"
    
        def draw(self, context):
            # Store reference to context.scene
            scn = context.scene
            # Store reference to self.layout
            lay = self.layout
            # Create box
            box = lay.column_flow(2)
            box.operator("object.simple_operator", text="Print #1")
            box.prop(scn, 'encouraging_message')
            box.operator("object.simple_operator", text="Print #1")
            box.prop(scn, 'encouraging_message')
            box.operator("object.simple_operator", text="Print #1")
    
            # Create another box
            box = lay.box()
            # Create a row within it
            row = box.row()
            # We can jam a few things on the same row
            row.operator("object.simple_operator", text="Print #2")
            row.prop(scn, 'encouraging_message')
            # Create yet another box
            box = lay.box()
            # Create a row just for a label
            row = box.row()
            row.label('There is a split row below me!')
            # Create a split row within it
            row = box.row()
            splitrow = row.split(percentage=0.2)
            # Store references to each column of the split row
            left_col = splitrow.column()
            right_col = splitrow.column()
            left_col.operator("object.simple_operator", text="Print #3")
            right_col.prop(scn, 'encouraging_message')
    
            # Throw a separator in for white space...
            lay.separator()
            # We can create columns within rows...
            row = lay.row()
            col = row.column()
            col.prop(scn, 'my_int_prop')
            col.prop(scn, 'my_int_prop')
            col.prop(scn, 'my_int_prop')
            col = row.column()
            col.prop(scn, 'my_float_prop')
            col.label("I'm in the middle of a column")
            col.prop(scn, 'my_float_prop')
            # Throw a few separators in...
            lay.separator()
            lay.separator()
            lay.separator()
            # Same as above but with boxes...
            row = lay.row()
            box = row.box()
            box.prop(scn, 'my_int_prop')
            box.label("I'm in the box, bottom left.")
            box = row.box()
            box.prop(scn, 'my_bool_prop')
            box.operator("object.simple_operator", text="Print #4")
    
        @classmethod
        def register(cls):
            print("Register class: %s" % cls.bl_label)
    
        @classmethod
        def unregister(cls):
            print('Unregister class: %s' % cls.bl_label)
    
  • 相关阅读:
    ubuntu下安装flash
    PHPMailer邮件发送
    PHP制作简单分页(从数据库读取记录)
    windows下安装PHP环境
    捕获浏览器关闭,刷新事件
    ubuntu下安装wps
    用PHP制作一个简单的验证码
    一个PHP程序员应该掌握的10项技能!
    爬虫框架之scrapy
    Android杂谈禁止TimePicker控件通过keyboard输入
  • 原文地址:https://www.cnblogs.com/yaoyu126/p/9318667.html
Copyright © 2011-2022 走看看