ui_menu_simple.py 571 B

12345678910111213141516171819202122232425262728
  1. import bpy
  2. class SimpleCustomMenu(bpy.types.Menu):
  3. bl_label = "Simple Custom Menu"
  4. bl_idname = "OBJECT_MT_simple_custom_menu"
  5. def draw(self, context):
  6. layout = self.layout
  7. layout.operator("wm.open_mainfile")
  8. layout.operator("wm.save_as_mainfile")
  9. def register():
  10. bpy.utils.register_class(SimpleCustomMenu)
  11. def unregister():
  12. bpy.utils.unregister_class(SimpleCustomMenu)
  13. if __name__ == "__main__":
  14. register()
  15. # The menu can also be called from scripts
  16. bpy.ops.wm.call_menu(name=SimpleCustomMenu.bl_idname)