[ Solved ] Pop up for error or message

I saw the example for pop up for error or messages
and this is done with class operator
and use in a panel

now I want to use this in and add mesh operator

is it possible ?

I tried it in the draw part of a class operator and it is not working

got this and error on the call to the operator

va_buf.msg_type = ‘Error :’
va_buf.msg = ‘Got your error here’

bpy.ops.va.msg_id(‘INVOKE_DEFAULT’)

print (’ error recorded = Error1’)

thanks

Use a props dialog:

import bpy

class SimpleOperator(bpy.types.Operator):
    """Tooltip"""
    bl_idname = "object.simple_operator"
    bl_label = "Simple Object Operator"
    bl_options = {'REGISTER', 'UNDO'}
    
    name = bpy.props.StringProperty(name="Name")
    val = bpy.props.IntProperty(name="Value", min=1, max=100)
        

    def execute(self, context):
        print("Name: %s" % self.name)
        print("Value: %i" % self.val)
        return {'FINISHED'}
    
    def draw(self, context):
        layout = self.layout

        layout.prop(self, "name")
        layout.prop(self, "val")
        
    def invoke(self, context, event):
        return context.window_manager.invoke_props_dialog(self)


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


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


if __name__ == "__main__":
    register()

    # test call
    bpy.ops.object.simple_operator('INVOKE_DEFAULT')


I can call the class with an operator call

but cannot call it directly that is the problem !

like I want to call it on an error from inside the draw func is it possible ?

like let say error on a calculations

if X1 > 5 :

call the class  pop up !

thanks

I want to call it on an error from inside the draw func is it possible ?

No, and you really shouldn’t do such things.

In a panel, you could instead display a warning icon or text.

I move the code for error in the execute part and seems to work now!

so I guess it is solved

but why it is not working in the draw part ?

thanks

cause “self” is a self-reference which differs. report() is a function of bpy.types.Operator, Panels don’t have it. I would also be bad design to run actions from draw code and in fact a lot of the blend data is protected against changes during drawing.

why then can you call it with an operator in the draw part ?

sub_l.operator(‘va.op0_id’, text = 'Select Vertex ') # Error help

thanks

operator() is a function of bpy.types.Panel to add a representation of an operator to the layout, I don’t get your point. No operator is called.

right this was part of a panel class not a class operator !

thanks