Make Python script wait for popup to return

Hello all, I’m working on a preprocessing script that requires user input on whether they want to overwrite a file or not. I was planning on using op.TDResources.PopDialog.OpenDefault to create a popup and depending on what it returns proceed. Unfortunately I need to process multiple files in a for loop and the python script will not wait for the dialog to finish. Because of this the user input is not able to be processed. Is there a way to pause execution until the popup returns?
My sudo code looks like:

for file in list_of_files:
  if user clicked ok:
    do something


Soooooo, yeah.
If this is abou selecting files, you can actually use the
ui.chooseFile(load=True, start=None, fileTypes=None, title=None, asExpression=False)
method (Docs)
If you need any kind of selection, use
ui.messageBox(title, message, buttons=['Ok'])
for anything else you will need to dife in to callbackHell.

So, the issue is, even though the previous mentioned function do exactly that, TD does not support async operations. (Some cooking dependency, framelock yada yada, i’m sure @greg knows who can shed light on that).
So, instead you have to cut your operations in to small chunks and define seperate function. You can do this dynamicly, so this is not to hard inititaly, but can be (and get) confusing.

def menuChoice(info):
	op(info['item']).current = True

menuItems = [ for child in parent().children]


Taken streight from docs from exaple3:

1 Like

thanks for the reply, that makes sense. I assumed this was an async limitation. For my pretty simple use case I think I can use the ui.messageBox(title, message, buttons=['Ok']) approach. Thank you, I didn’t know that it existed.