← Back to team overview

sikuli-driver team mailing list archive

[Question #255202]: How to use functions with a default region

 

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

Hi,

I'm trying to create a function where the caller can optionally pass a region, if no region is passed the Screen region should be used as default, but this is not working. What am I doing wrong?

This is my function:

def tryClick(img,reg=Screen, delay = 5):
    if reg.exists(img,delay):
        reg.click(reg.getLastMatch())
        return True
    else:
        print("tryClick failed for pattern" +str(img))
        return False

calling lines might be something like:

tryClick("img.png") #use Screen as region
tryClick("img2.png", myRegion) #use myRegion as region
tryClick("img3.png",myRegion2,60) #use myRegion2 and wait for one minute

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