Callback when an observation timeout

Asked by horiel

Hello,
I am using the 1.1.x Sikuli version

when doing:
def changed(event):
        print "something changed in ", event.region

my_region.onChange(50, changed)
my_region.observeInBackground(10)

Is there a way to have a callback after 10 seconds if the observation timeout ? Something like:
my_region.onTimeOut(callback)

Thanks a lot

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
horiel
Solved:
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#1

If there is nothing else to do during the onChange-observation, then just use the normal observe() which just waits for the success or finally the timeout.

success = false

def changed(event):
        global success
        success = true
        print "something changed in ", event.region

my_region.onChange(50, changed)
my_region.observe(10)
if success:
  pass # do something
else:
  pass # do something else

Revision history for this message
horiel (alexis-jacquelin) said :
#2

thx Raiman for the response, I will do that.