The file selection dialog is launched from context.window_manager.fileselect_add(op) — but it returns immediately to the calling python routine, long before the user has selected a file or cancelled it. I need a modal version — one that doesn’t return until the user has closed the dialog. In my case the file selection dialog may pop up any number of times during the execution of a very large (machine-generated) script, and in each case the selected file is required before the script can continue running.
I understand that in blender the file selector is typically used in import and export modules where just one file is needed and all the work can all be put into the execute routine, but that isn’t possible here. Neither is a reorganization/breakup of the script. I need a fileselect-add variant that operates like the normal modal windows/macOS/linux file selectors, where you put it up, and control doesn’t return until the dialog is closed.
I’ve tried an approach using a flag set by the execute and cancel routine, with a polling loop in the main python code, but that shuts down blender’s message loop and it hangs. If there isn’t a better non-polling solution, how can I get blender to process its message queue within the polling loop?
Note: putting a test in the operator’s modal function doesn’t work; it is never called.
This is all part of a substantial blender 2.80 conversion and upgrade.