← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #288480]: Using observe() for region created via default argument

 

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

    Status: Open => Answered

RaiMan proposed the following answer:
at least this is not correct:
observe_region.onChange(100, observe_region.stopObserver())

must be
observe_region.onChange(100, observe_region.stopObserver)

... the handler has to be given with its name, not as the function call,
which runs it in this moment - hence stops the observer.

... and it is recommended to define a real handler for the observing,
which gives you more options to track what happens.

def changeHandler(event):
     print "in changeHandler"
     event.stopObserver() 

def wait_load(observe_region=Region(399,25,1040,406)):
    observe_region.onChange(100,changeHandler)
    observe_region.observe(20)

-- 
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.