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.


    How to use ui.delay()

    Pythonista
    2
    4
    3325
    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.
    • ?
      A Former User last edited by

      I can't find any example of how to use ui.delay(). I've tried what seems the obvious simple case below, but the function always runs immediately... without any delay. Can you provide an example please. Thank you, Tony.

      import ui
      import console
      
      def funcSome ():
      	console.hud_alert('funcSome')
      	
      ui.delay(funcSome(), 3)
      
      1 Reply Last reply Reply Quote 1
      • ccc
        ccc last edited by

        Remove the () so that you are passing the function instead of calling the function.

        Change the last line to: ui.delay(funcSome, 3).

        1 Reply Last reply Reply Quote 0
        • ?
          A Former User last edited by

          Brilliant, thanks. All is clear, Tony.

          1 Reply Last reply Reply Quote 0
          • ?
            A Former User last edited by

            ... and now you got me started... with a bit of research... I discovered you can do this if you need to pass arguments:

            import ui
            import console
            from functools import partial
            
            def funcSome (a, b):
            	console.hud_alert(a + b)
            	
            ui.delay(partial(funcSome, 'a', 'b'), 3)
            
            1 Reply Last reply Reply Quote 2
            • First post
              Last post
            Powered by NodeBB Forums | Contributors