It’s simpler than you think.
In Python, when you pass a function as an argument, you automatically pass its context as well.
This means that a function callback can be a method of an object (and then you can access the object), or a lambda function that can access any variable through its closure.
Here is an example:
lv.task_create(lambda task: toggle_task(btn), 1000, lv.TASK_PRIO.HIGH, None)
In this example we pass
btn as an argument to the callback function
toggle_task, using a lambda.
There are many other ways to do it in Python. For example passing an object’s method as the callback.
You can use the same technique with
async_call, or any other function that receives a callback.