ui_panel.py 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. import bpy
  2. class LayoutDemoPanel(bpy.types.Panel):
  3. """Creates a Panel in the scene context of the properties editor"""
  4. bl_label = "Layout Demo"
  5. bl_idname = "SCENE_PT_layout"
  6. bl_space_type = 'PROPERTIES'
  7. bl_region_type = 'WINDOW'
  8. bl_context = "scene"
  9. def draw(self, context):
  10. layout = self.layout
  11. scene = context.scene
  12. # Create a simple row.
  13. layout.label(text=" Simple Row:")
  14. row = layout.row()
  15. row.prop(scene, "frame_start")
  16. row.prop(scene, "frame_end")
  17. # Create an row where the buttons are aligned to each other.
  18. layout.label(text=" Aligned Row:")
  19. row = layout.row(align=True)
  20. row.prop(scene, "frame_start")
  21. row.prop(scene, "frame_end")
  22. # Create two columns, by using a split layout.
  23. split = layout.split()
  24. # First column
  25. col = split.column()
  26. col.label(text="Column One:")
  27. col.prop(scene, "frame_end")
  28. col.prop(scene, "frame_start")
  29. # Second column, aligned
  30. col = split.column(align=True)
  31. col.label(text="Column Two:")
  32. col.prop(scene, "frame_start")
  33. col.prop(scene, "frame_end")
  34. # Big render button
  35. layout.label(text="Big Button:")
  36. row = layout.row()
  37. row.scale_y = 3.0
  38. row.operator("render.render")
  39. # Different sizes in a row
  40. layout.label(text="Different button sizes:")
  41. row = layout.row(align=True)
  42. row.operator("render.render")
  43. sub = row.row()
  44. sub.scale_x = 2.0
  45. sub.operator("render.render")
  46. row.operator("render.render")
  47. def register():
  48. bpy.utils.register_class(LayoutDemoPanel)
  49. def unregister():
  50. bpy.utils.unregister_class(LayoutDemoPanel)
  51. if __name__ == "__main__":
  52. register()