← Back to team overview

sikuli-driver team mailing list archive

[Question #685286]: Sikuli Doc - Example code returns error

 

New question #685286 on Sikuli:
https://answers.launchpad.net/sikuli/+question/685286

Was just reading this: 
http://doc.sikuli.org/region.html#observing-visual-events-in-a-region

copy pasted the code in sikuli:

def changed(event):
        print "something changed in ", event.region
        for ch in event.changes:
                ch.highlight() # highlight all changes
        sleep(1)
        for ch in event.changes:
                ch.highlight() # turn off the highlights
with selectRegion("select a region to observe") as r:
    # any change in r larger than 50 pixels would trigger the changed function
    onChange(50, changed)
    observe(background=True)

wait(30) # another way to observe for 30 seconds
r.stopObserver()


and I'm getting the following error:


[error] script [ Untitled ] stopped with error at line --unknown--
[error] Error caused by: Traceback (most recent call last): File "C:\Users\testUser\AppData\Local\Temp\Sikulix_367046279\sikuli-2894467953142955615.py", line 1, in <module> def changed(event): AttributeError: 'org.sikuli.script.Region' object has no attribute '__exit__' 


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