Unreal Python: How to get dialogue box answer as a variable? Yes no cancel etc

Hi there,
This is super simple but I can’t remember how to do it properly, and I can’t find the answer anywhere.
I am using “unreal.EditorDialog.show_message” to popup a user message. But how do I then what’s the cleanest way to do an if/then statement for the result?

unreal.EditorDialog.show_message("My window name", "Would you like to continue?", unreal.AppMsgType.YES_NO)

I’ve tried building an IF statement based on the help page (ie. with the AppReturnType stuff), but there’s unfortunately no example there for me to understand. (I wish my memory would let me remember code from several years ago, because this hasn’t changed in a while, I know! I just can’t find any examples in my own stuff)

https://docs.unrealengine.com/5.2/en-US/PythonAPI/class/EditorDialog.html#unreal.EditorDialog

toby (virtual filmer)

I meant to include this… I have code working, but it’s inelegant as heck lol. There must be an easier way to do this?

temp_mydialogue = unreal.EditorDialog.show_message("Window name", "Would you like to do this thing?", unreal.AppMsgType.YES_NO)
temp_mydialogue_string = str(temp_mydialogue)
if ("YES" in temp_mydialogue_string):
	print("You clicked yes.")
if ("NO" in temp_mydialogue_string):
	print("You clicked no.")
1 Like

Hi I found the right way , if it’s help someone .

test = unreal.EditorDialog.show_message("My window name", "Would you like to continue?", unreal.AppMsgType.YES_NO)
if (test == unreal.AppReturnType.YES) :
    print("OK")
else:
    print("NO")

to help me to find I I use :print(type(test))
result LogPython: <class ‘AppReturnType’>

have a nice day.
Daniel