Here is a very trivial very small very complete add-on. It draws one button in one panel that shows up as the "TLA" tab in the 3D Viewport when the Viewport is in Object Mode. It only has two classes, but it uses a common technique to register multiple classes by putting their names in an array and processing the array.
For each button you want, add an operator Class with a different name and a new col.operator
.
# Very small add on to start from
bl_info = {
"name" : "draw colors",
"description" : "A skeleton addon",
"author" : "Marty",
"version" : (0, 0, 1),
"blender" : (2, 80, 0),
"location" : "View3D",
"warning" : "",
"support" : "COMMUNITY",
"doc_url" : "",
"category" : "3D View"
}
import bpy
from bpy.types import Operator
from bpy.types import Panel
class TLA_OT_operator(Operator):
""" tooltip goes here """
bl_idname = "demo.operator"
bl_label = "I'm a Skeleton Operator"
bl_options = {"REGISTER", "UNDO"}
@classmethod
def poll(cls, context):
return context.mode == "OBJECT"
def execute(self, context):
self.report({'INFO'},
f"execute()")
return {'FINISHED'}
class TLA_PT_sidebar(Panel):
"""Display test button"""
bl_label = "TLA"
bl_space_type = "VIEW_3D"
bl_region_type = "UI"
bl_category = "TLA"
def draw(self, context):
col = self.layout.column(align=True)
prop = col.operator(TLA_OT_operator.bl_idname, text="Say Something")
classes = [
TLA_OT_operator,
TLA_PT_sidebar,
]
def register():
for c in classes:
bpy.utils.register_class(c)
def unregister():
for c in classes:
bpy.utils.unregister_class(c)
if __name__ == '__main__':
register()