← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #214725]: Facing issue while importing Sikuli script in Eclipse

 

Question #214725 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/214725

    Status: Open => Answered

RaiMan proposed the following answer:
Ok, this is now the crossing, where you have to decide going left or
right ;-)

There are some options, to solve the "image location problem", but I
will talk only about the most convenient ones:

*** Option 1: (using Sikuli's import support)
In the IDE make one or more imageX.sikuli, that only contain statements like:
from sikuli import *
imgXYZ = "some-captured-image.png"
patXYZ = Pattern(imgXYZ).similar(0.99).targetOffset(x,y)
.... and more of them

These .sikuli might contain additional code, that is once run when
imported or even some def()'s (helper functions), that can be used in
the main flow.

Have a naming convention for the variable names, either globally or
within one imageX.sikuli.

put all imagesX.sikuli in one folder e.g. path-to-myimages

In your main flow:
from sikuli import *
sys.path.append(path-to-myimages)
# with a global naming convention
from imagesX import *
click(imgXYZ)
find(patXYZ)

# with a naming convention per imagesX if more than one imageX is imported
import imagesX
import imagesY

click(imagesX.imgXYZ)
....
click(imagesY.imgXYZ)

This is convenient, since you can use the IDE, to manage the
imagesX.sikuli.

*** Option 2:
use the Sikuli imagePath feature (see http://doc.sikuli.org/globals.html#getImagePath)
This needs a naming convention for the image filenames and you have to use these filenames in your code.
IMHO Option 1 is more flexible and transparent.

-- 
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.