ui_panel_simple.py 837 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. import bpy
  2. class HelloWorldPanel(bpy.types.Panel):
  3. """Creates a Panel in the Object properties window"""
  4. bl_label = "Hello World Panel"
  5. bl_idname = "OBJECT_PT_hello"
  6. bl_space_type = 'PROPERTIES'
  7. bl_region_type = 'WINDOW'
  8. bl_context = "object"
  9. def draw(self, context):
  10. layout = self.layout
  11. obj = context.object
  12. row = layout.row()
  13. row.label(text="Hello world!", icon='WORLD_DATA')
  14. row = layout.row()
  15. row.label(text="Active object is: " + obj.name)
  16. row = layout.row()
  17. row.prop(obj, "name")
  18. row = layout.row()
  19. row.operator("mesh.primitive_cube_add")
  20. def register():
  21. bpy.utils.register_class(HelloWorldPanel)
  22. def unregister():
  23. bpy.utils.unregister_class(HelloWorldPanel)
  24. if __name__ == "__main__":
  25. register()