[HowTo] Passing extra arguments to observe's onXXX event handlers

Asked by Mikeldi Latorre

Just wanted to share this:

If you need to pass some extra argument apart from the event, you can do it like this:

x="extra argument"

onAppear(img, lambda event, arg=x: handler(event, arg))
observe(timeout)

def handler(event, arg):
    print(arg)
    stopObserver()

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
Mikeldi Latorre
Solved:
Last query:
Last reply:
Revision history for this message
Mikeldi Latorre (magodiez) said :
#1

Just to share some useful information

Revision history for this message
RaiMan (raimund-hocke) said :
#2

Thanks for sharing. I will add it to the docs.