← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #166280]: AttributeError: 'Region' object has no attribute 'StopObserver'

 

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

    Status: Open => Answered

RaiMan proposed the following answer:
An observe() is always "connected" to a region. Using just observe()
"connects" it to the default region SCREEN, which is a constant Region
object setup at Sikuli startup as SCREEN = Screen(0). Each Region/Screen
method, that is used without a Region/Screen qualifier is automagically
used as SCREEN.method().

So in your case, the problem is StopObserver(), which has to be stopObserver()
(see: http://sikuli.org/docx/region.html#Region.stopObserver).

Your "fix" works, because the onAppear() is "connected" to
myFileDownloadRegion and the observe() is "connected" to region SCREEN,
so the handler is never called in this case and so does not produce the
error any more.

This would be a correct version:

myFileDownloadRegion = Region(15,25,1010,698)
def myObserverHandler(event):
    event.region.stopObserver()# stops the observation
myFileDownloadRegion.onAppear( '/sikuli/project/UserSecurity.png', myObserverHandler)
myFileDownloadRegion.observe(60)

BTW: Region.inside() is only there for downward compatibility to Sikuli
0.9. With Sikuli X it makes no sense any longer, since it only returns
the region itself.

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