omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    @omz DropboxFilePicker (synchronous version)

    Pythonista
    synchronous dropbox
    2
    4
    3635
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Phuket2
      Phuket2 last edited by

      @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

      1 Reply Last reply Reply Quote 0
      • JonB
        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.

        Phuket2 2 Replies Last reply Reply Quote 1
        • Phuket2
          Phuket2 @JonB last edited by

          @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.

          1 Reply Last reply Reply Quote 0
          • Phuket2
            Phuket2 @JonB last edited by

            @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.

            1 Reply Last reply Reply Quote 0
            • First post
              Last post
            Powered by NodeBB Forums | Contributors