I try to show some images in the panel.
This is the source code:
import bpy
class MyPanel(bpy.types.Panel):
bl_label = "My Panel"
bl_idname = "OBJECT_PT_my_panel"
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
bl_category = "My Tools"
def draw(self, context):
layout = self.layout
# Load the images
icons = []
for i in range(1, 4):
image_path = "C:/BACKUP/3D/catafest{}.png".format(i)
icon = bpy.data.images.load(image_path)
icons.append(icon)
# Display the images
layout.label(text="My Images")
for icon in icons:
row = layout.row()
row.scale_y = 2.0
row.prop(icon, "preview_id", icon_only=True, expand=True)
# Add operator button
layout.operator("object.my_operator", text="My Operator")
class MyOperator(bpy.types.Operator):
bl_idname = "object.my_operator"
bl_label = "My Operator"
def execute(self, context):
self.report({'INFO'}, "My Operator was called")
return {'FINISHED'}
classes = [MyPanel, MyOperator]
def register():
for cls in classes:
bpy.utils.register_class(cls)
def unregister():
for cls in reversed(classes):
bpy.utils.unregister_class(cls)
if __name__ == "__main__":
register()
but not work, this is the result :