Location.getX() and getY() return Python-float/Java-double (from java.awt.Point) - should return int

Asked by Roman Podolyan

Sikuli X-1.0rc1

I met an issue with Location.getX() / getY on Mac OS X Snow Leopard - it seems that return type isn't int, and I can't pass it to a function requiring int without a type converion.

# this works:
tmpx = int(mylocation.getX()) + 100
...
end = Location(tmpx,100)

# and this works:
tmpx = mylocation.x + 100
...
end = Location(tmpx,100)

# and this doesn't:
tmpx = mylocation.getX() + 100
...
end = Location(tmpx,100)

It throws error "1st arg can't be coerced to int"

According to documentation and Q&A https://answers.launchpad.net/sikuli/+question/139814 , I think that something is wrong.

Am I right, or I just don't know something about Python?

Question information

Language:
English Edit question
Status:
Answered
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#1

absolutely right:

Class Location is defined on the Java level and does not have it's own get/set methods inheriting it from java.awt.Point.

These getX, .... return a double (Python float) value.

I will change the doc accordingly and report a bug so that the developers may decide to implement get methods returning int.

So just use .x and .y (which are read/write attributes) for now.

Thanks for your input

Can you help with this problem?

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

To post a message you must log in.