bl_info = {
"name": "",
"description": "",
"author": "",
"blender": (2, 80, 0),
"version": (0, 0),
"category": "",
"location": "3D View > UI > Create",
"warning": "",
}
import boy
class PrinterFunction(bpy.types.Operator):
"""desc"""
bl_idname = "print.helloworld"
bl_label = "Hello World"
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
print('hi world')
return {'FINISHED'}
class OBJECT_PT_hw(bpy.types.Panel):
bl_idname = "object_PT_hw"
bl_label = "hw"
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
bl_category = "Create"
bl_context = "objectmode"
def draw(self, context):
self.layout.use_property_split = True
self.layout.operator('print.helloworld', icon="IMPORT", text="Rename here")
classes = (
PrinterFunction,
OBJECT_PT_hw,
)
def register():
from bpy.utils import register_class
for cls in classes:
register_class(cls)
def unregister():
from bpy.utils import unregister_class
for cls in reversed(classes):
unregister_class(cls)
if __name__ == "__main__":
register()
FYI: Blender already has many useful python templates. You can access them from here