← Back to team overview

sikuli-driver team mailing list archive

[Question #265514]: List, object has no attribute 'hasNext'

 

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

Hello, Colleagues.
Need your help.
I'm trying to click on all found image, previously sorted, except the last.
Here's my code:

def order(match):
    return match.y, match.x
def CLICKER():
    scr1 = Screen(1)
    pat = Pattern("1429518580337.png").similar(0.95)
    icons = scr1.findAll(pat)
    sorted_icons = sorted(icons, key=order)
    for icon in sorted_icons:
        print icon
        scr1.click(icon)
        CLICKER()
        break
CLICKER()

I'm using recursion to find image again on each step, because after one image is clicked, others change position. 
Also use scr1 = Screen(1), because image on my second monitor.
It successfully clicks on all images. But I need to add condition hasNext()  to do not click on the last image.
I've tried: 
(1) if icon.hasNext() == 'True':
     get an [error] AttributeError ( 'org.sikuli.script.Match' object has no attribute 'hasNext' ) 
(2) if icons.hasNext() == 'True':
     no error - but clicks only first image
(3) if sorted_icons.hasNext() == 'True':
     [error] AttributeError ( 'list' object has no attribute 'hasNext' )

How to add hasNext() condition?
Thanks very much for you help.


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