[2.0.4] Region methods getRow and getCol does not work --- fixed in 2.0.5

Asked by TestMechanic on 2020-12-17

Seems like getRow and getCol methods does not work
https://sikulix-2014.readthedocs.io/en/latest/region.html#Region.getRow

tested with sikuli 2.0.4

reg = getRow(3,4)
reg.highlight(2)

Above code always select the whole screen

Question information

Language:
English Edit question
Status:
Answered
For:
Sikuli Edit question
Assignee:
No assignee Edit question
Last query:
2020-12-17
Last reply:
2020-12-21
masuo (masuo-ohara) said : #1

I've also noticed before that getRow and getCol don't work with two arguments.
When I need them, I am using setRaster.

[example]
r = Region(100,100,600,200)
r.highlight(1)
MAXROWS = 3
MAXCOLUMNS = 4
r.setRaster(MAXROWS,MAXCOLUMNS)
for row in range(0,MAXROWS):
    r.getRow(row).highlight(1)
    for col in range(0,MAXCOLUMNS):
        r.getCell(row,col).highlight(1)

Simon Plivav (simpliv742) said : #2

reg = getRow(3,4)

What you wrote is bad style, or even not functional. What is your intention, to get a cell or a row?

[Below reg = Region(something, e.g. SCREEN)]

You should provide a region that is having rows set up by reg.setRows(3). Then get a row as row=reg.getRow(2)

With two arguments like you tried you should have used reg.setRaster(x, y), then you can select cells of that raster like reg.getCell(2,2).

TestMechanic (ndinev) said : #3

I am using it correctly according to the documentation

getRow(3,4) > means to divide screen(default) in 4 rows and get the forth one (it is zero based 0,1,2,3)

Here is the excerpt from documentation

***
If you need only one row in one column with x rows or only one column in one row with x columns you can use Region.getRow() or Region.getCol()

getRow(whichRow, numberRows)
    Parameters:

        numberRows – in how many evenly sized rows should the region be devided
        whichRow – the row to select counting from 0, negative counts backwards from the end

    Returns:

    a new Region created from the selected row
***

RaiMan (raimund-hocke) said : #4

LOL, should have checked a bit earlier :-((

@TestMechanic
You are completely right.

... but it is not implemented - simply returns the actual region - really sorry.

getCols(I, n) works as documented.

I will fix it in 2.0.5.

workaround:
setRows(4); getRow(3)

Can you help with this problem?

Provide an answer of your own, or ask TestMechanic for more information if necessary.

To post a message you must log in.