← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #670456]: General error handling

 

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

RaiMan proposed the following answer:
To be on the safe side with the current implementation, you should act
so:

def ffhandler(event):
  print "in FindFailed handler"

FindFailed.setHandler(ffhandler) # set as global handler even for Regions
use() # reset the global SCREEN object to take over the handler setting

This must be inserted at the top of the main script.

If you want this behavior in any imported script (having "from sikuli
import *" at the beginning), then those scripts need this also.

If you want to share the handler among scripts, then it must be in one
script

# FindFailedHandling.sikuli
from sikuli import *
def ffhandler(event):
  print "in FindFailed handler"

and then in the script that needs it:
from sikuli import *
from FindFailedHandling import *
FindFailed.setHandler(ffhandler) 
use() 

in the main script the
from sikuli import *
is not needed

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