this (code snippets) used to be my go-to-reference for buttons and other gui things, now it seems to just do nothing…
#----------------------------------------------------------
# File layout.py
#----------------------------------------------------------
import bpy
class LayoutPanel(bpy.types.Panel):
bl_label = "Panel with funny layout"
bl_space_type = "VIEW_3D"
bl_region_type = "TOOL_PROPS"
def draw(self, context):
layout = self.layout
layout.label("First row")
row = layout.row(align=True)
row.alignment = 'EXPAND'
row.operator("object.Button", text="1")
row.operator("object.Button", text="2", icon='MESH_DATA')
row.operator("object.Button", icon='LAMP_DATA')
row = layout.row(align=False)
row.alignment = 'LEFT'
row.operator("object.Button", text="4")
row.operator("object.Button", text="", icon='MATERIAL')
row.operator("object.Button", text="6", icon='BLENDER')
row.operator("object.Button", text="7", icon='WORLD')
layout.label("Third row", icon='TEXT')
row = layout.row()
row.alignment = 'RIGHT'
row.operator("object.Button", text="8")
row.operator("object.Button", text="9", icon='SCENE')
row.operator("object.Button", text="10", icon='BRUSH_INFLATE')
layout.label("Fourth row", icon='ACTION')
row = layout.row()
box = row.box()
box.operator("object.Button", text="11", emboss=False)
box.operator("object.Button", text="12", emboss=False)
col = row.column()
subrow = col.row()
subrow.operator("object.Button", text="13")
subrow.operator("object.Button", text="14")
subrow = col.row(align=True)
subrow.operator("object.Button", text="15")
subrow.operator("object.Button", text="16")
box = row.box()
box.operator("object.Button", text="17")
box.separator()
box.operator("object.Button", text="18")
box.operator("object.Button", text="19")
layout.label("Fifth row")
row = layout.row()
split = row.split(percentage=0.25)
col = split.column()
col.operator("object.Button", text="21")
col.operator("object.Button", text="22")
split = split.split(percentage=0.3)
col = split.column()
col.operator("object.Button", text="23")
split = split.split(percentage=0.5)
col = split.column()
col.operator("object.Button", text="24")
col.operator("object.Button", text="25")
class OBJECT_OT_Button(bpy.types.Operator):
bl_idname = "OBJECT_OT_Button"
bl_label = "Button"
def execute(self, context):
print("Hello world!")
return{'FINISHED'}
used to display a variety of buttons and layout details, now it just goes silent.
what’s the deal, the current way of doing it is not as obvious as it used to be.