Modal, dynamic message box to confirm a selection

I need a simple, modal dialog box with a dynamic text and Yes/No buttons. Ideally, I’d like to access it with something like:

if msgBox(title,message,icon) == 'FINISHED':
#YES clicked
     <do something>
#NO clicked
     <do something else>

I looked through api and searched the web, but the solutions I find are either too rigid or overly complicated.
I am hoping someone here has a class with this function ready-to-go and is willing to share the code :slight_smile:

This is not the solution but maybe helpful


import bpy
class SimpleOperator(bpy.types.Operator):
    bl_idname = "object.test"
    bl_label = "Confirm"
    confirm = bpy.props.EnumProperty(
        items= [

    def execute(self, context):

        return {'FINISHED'}
    def invoke(self, context, event):
        return context.window_manager.invoke_props_dialog(self)
    def draw(self,context):
        self.layout.prop(self, "confirm", expand=True)
1 Like

Hi Yashar,
Sorry for the late reply and thank you for your contribution! I like the dialog, despite the redundant confirmation. But it’s not modal, so I can’t cancel a procedure with this, which is the whole point.
Any idea how to fix that?