location class

Asked by Albert

Hi,

I'm having problems with the location class:
-------
class location:
 Location(x,y)
 location.x = PICTURE
 location.y = PICTURE
setLocation(x,y)
-------
it should set x and y as the coordinates for the location object, right? It throws up an error at line 2: name x is not defined.
Please help me :)

Question information

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

not sure, what you are trying to do.

Did you read the docs? (http://sikuli.org/docx/)

The class Location is already defined by Sikuli. It denotes a pixel on the screen.
You define a new location by:
myLoc = Location(some_x, some_y)

Some functions return a Location object:
upperLeftCorner = find("some-image.png").getTopLeft()
centerPixel = find("some-image.png").getCenter()

and other functions accept locations as input
mouseMove(myLoc)

hope it helps.

--- your error in your snippet:
when Python tries to run
Location(x,y) it says, that x is not defined yet.
When using variables, they have to be defined (e.g. x = 10) before used the fist time.

Revision history for this message
Albert (alberttarcy) said :
#2

Thanks RaiMan, that solved my question.