@omz DropboxFilePicker (synchronous version)
@omz, is it a trivial matter to get your DropboxFilePicker utility to work synchronously rather than on ui.background. Well, the real question, can it easily be made to work so that wait_modal works. Want to include into a step as part of a bigger process. I have had some feeble attempts to modify, without much luck. First thing I tried was just to comment the @ui.background wrappers. I am sure, a bit more needs to be done.
Look, I know you must be busy. But if it's simple, would be great to have it. I also think also could benefit the community. If it's something you don't have time for. That's fine, with your permission, I will try and cut up your code and try again.
The gist at Pythonista Tools Repo/site
JonB last edited by
i had success simply replacing @ui.in_background with @run_async:
def run_async(func): from threading import Thread from functools import wraps @wraps(func) def async_func(*args, **kwargs): func_hl = Thread(target = func, args = args, kwargs = kwargs) func_hl.start() return func_hl return async_func
then wait_modal works.
@JonB , that's why you get paid the big bucks 😱
Really thank you. May have seemed easy to you, but not to me.
But your solution works perfect for me also.
@JonB , I searched for conditional decorators. So I found some stuff on stackflow. Not exactly what they did, but I did this and it seems to work.
_USE_ASYNC = False def cond_decorator(func): from threading import Thread from functools import wraps @wraps(func) def async_func(*args, **kwargs): func_hl = Thread(target = func, args = args, kwargs = kwargs) func_hl.start() return func_hl if _USE_ASYNC: return async_func else: return ui.in_background(func)
Just so the DropboxFilePicker can work either way.