Forum Archive

How to use ui.delay()

[deleted]

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)
ccc

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

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

[deleted]

Brilliant, thanks. All is clear, Tony.

[deleted]

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