Assign every Match from findAll to a separate variable

Asked by spyros-liakos

Hi there.....I go this script:

#-----------------------------------------------------------#

Search = Region(100,100,1000,1000)

img = "img.png"

get_x = 0
get_y = 0

Region.Search.findAll(img)

result = Search.getLastMatches()

for matches in result:
 get_x = matches.getX()
 get_y = matches.getY()
 print "Found for X: ", get_x
 print "Found for Y: ", get_y

#-----------------------------------------------------------#

**The log is this which is ok, it founds the images I want!

Found for x: 566
Found for y: 294
Found for x: 617
Found for y: 363
Found for x: 484
Found for y: 294
Found for x: 433
Found for y: 363

BUT: I want for every match to store x-y values to a separate variable, so I can manipulate my model...
How I can achieve that....??????????

Thanks....

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
spyros-liakos
Solved:
Last query:
Last reply:
Revision history for this message
masuo (masuo-ohara) said :
#1
Revision history for this message
spyros-liakos (spy-arts) said :
#2

Yes but how to store every match x- y in a separate variable?? thats my problem...

Revision history for this message
masuo (masuo-ohara) said :
#3

mlist = []
for matches in result:
    mxy = []
    mxy.append(matches.getX())
    mxy.append(matches.getY())
    mlist.append(mxy)

#---example when you want to use mlist---
print mlist[0][0],mlist[0][1]

Revision history for this message
spyros-liakos (spy-arts) said :
#4

Great thanxns@@@!!!!!

Revision history for this message
masuo (masuo-ohara) said :
#5

If you use the method shown in the document

findAll("someimage.png")
mm = list(getLastMatches())
for i in range(len(mm)):
    print mm[i].getX(),mm[i],getY()