# How to script add-on info and warnings? [duplicate]

What is the best way to inform users of an add-on's warnings, info, or things they must do for the function to work? As it seems to be hard to add info to the main header, is it better to use (Blender dreaded) pop-ups? So what are your preferred ways and how do you do it, code-wise?

(I don't mean info view or console, because users do not have these things open - so this is not a duplicate question)

Prefered way is to use Operator.report() method. You only need to pass a certain type of report 'INFO', 'ERROR', 'WARNING' etc. and the corresponding message as string. In case of an error report a popup appears as well as the message is shown in the info bar, automatically.

import bpy
import random

class SimpleOperator(bpy.types.Operator):
"""Tooltip"""
bl_idname = "object.simple_operator"
bl_label = "Simple Object Operator"

@classmethod
def poll(cls, context):
return context.active_object is not None

def execute(self, context):
if bool(random.getrandbits(1)):
self.report({'ERROR'}, 'Error message')
else:
self.report({'INFO'}, 'Info message')
return {'FINISHED'}

def register():
bpy.utils.register_class(SimpleOperator)

def unregister():
bpy.utils.unregister_class(SimpleOperator)

if __name__ == "__main__":
register()


Example based on Python > Templates > Operator Simple.

import bpy

• Prefered way is to use Operator.report() method, check out the API: docs.blender.org/api/current/… – brockmann Dec 17 '17 at 14:14
• This blocks the user interface, which is against Blender's UI paradigm. Use Operator.report() instead. – dr. Sybren Dec 18 '17 at 13:16