Question #261418 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/261418

RaiMan proposed the following answer:
ok, no problem.

say you have just this line
onAppear("someImage.png", paste("text"))

let us look, what the Jython interpreter does when he arrives at this
line (somewhat simplificated):

1. sees the name onAppear and knows, that this is defined as a method in class 
Region and takes 2 parameters
2. finds the 2 items comma separated enclosed in pair of brackets
3. so the onAppear is correct and is pushed on a stack
4. as 1st parameter it sees "someImage.png" - nothing to evaluate - just push 
on stack
5. as 2nd parameter it finds paste("text"), which is now processed similar like 
the steps 1 - 4 for the Region method paste
6. after having pushed paste and "text" to the stack, nothing more to evaluate 
on this line
7. now the line can be executed - nothing happened until now
8. now the stack is resolved and executed backwards (popped)
9. the paste("text") is executed, does nothing of value at this moment and is 
replaced by the return value (0 or 1) on the stack
10. now the onAppear can be executed, which simply registers with the given 
region the advice, that when the next observe() is executed for this region, it 
should be checked, wether "someImage.png" has appeared. the second parameter is 
stored for future use as a callback target (handler name), when the image 
appears at the next observe.
11. still nothing happened until now (besides the useless paste), that has 
something to do with searching images

with version 1.0.1 (caused by the sloppy implementation) at the time of
this execution of onAppear, the mismatch of the second parameter (should
be the name of a handler function) was not detected and on top did not
show any problem during observe.

This has changed in 1.1.0 due to a more strictly implementation, so the
parameter mismatch is already detected when the onAppear is processed.

Why you got the impression, that this did something useful for you with
version 1.0.1: I cannot judge, because I do not know your workflow and
what happens on your screen.

So what observe does:
when you call observe() for a region it simply loops around the registered 
onXXX advices and for every onXXX that happens, it calls the registered handler 
function and waits until your handler finishes and returns.

lambda x,y,... : statement (see Python docs)

is simply a handler, that has no name (anonymous), but is a function
object, that is registered as handler function when used with onAppear
and that is called during observe, when the event happens. so it
produces a valid parameter.

I hope it helps.

-- 
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.

_______________________________________________
Mailing list: https://launchpad.net/~sikuli-driver
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~sikuli-driver
More help   : https://help.launchpad.net/ListHelp

Reply via email to