Question #264958 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/264958
Status: Open => Answered
RaiMan proposed the following answer:
m.x and m.y are the coordinates (x,y) of the matched rectangle on the
screen (top left corner).
This is Sikuli specific and documented here:
http://sikulix-2014.readthedocs.org/en/latest/index.html
To solve your problem is not trivial (even for a more experienced
scripter).
A list representing rows and columns looks like this:
m = []
m.append([11, 12, 13, 14])
m.append([21, 22, 23, 24])
m.append([31, 32, 33, 34])
m.append([41, 42, 43, 44])
"""
a 4 row, 4 column martrix
[[11, 12, 13, 14],
[21, 22, 23, 24],
[31, 32, 33, 34],
[41, 42, 43, 44]]
"""
# the martrix indices are counted from 0
print m # the complete matrix
print m[0] # the first row
print m[2,3] # the rightmost element in the 3rd row
# to print the second column
for i in range(4):
print m[i, 1]
depending on how exact your visual layout is (e.g. all matches in one
row have the same m.y values) the filling of this matrix more or less
complex.
if all the m.y values in one row are equal, this trick gives you list
containing all matches ordered in row and column
sortedMatches = sorted(matches, key=lambda m: m.y * 10000 + m.x)
now you might fill the above matrix to have a row/column representation
or simply use the list as is:
say you have k elements per row, then the rightmost element in the n-th row is:
sortedMatches[n*k + k - 1]
again: you touched a very complex situation very early in your starting
experience and should think over, wether this is the write approach.
version 1.1.0 has a feature to divide a region into even row and/or column
elements and address these elements by index.
(see the docs)
--
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.
_______________________________________________
Mailing list: https://launchpad.net/~sikuli-driver
Post to : [email protected]
Unsubscribe : https://launchpad.net/~sikuli-driver
More help : https://help.launchpad.net/ListHelp