← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #272509]: Images could not be loaded

 

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

    Status: Open => Answered

RaiMan proposed the following answer:
If you have something like this:

- a folder in MyScriptPath (preferably something like <some-path>/<you-name-it>.sikuli)
- in this folder there is a <you-name-it>.py
- in this folder you have a <someImage.png>
- and in your .py you have picture = "someImage.png"

then the easiest way is to say:
from  <you-name-it> import *

This will make the variable names known in your script and the folder is
auto-added to the image path, making the images accessible.

if your running script is not in the same folder as <you-name-it>.sikuli, then you have to say before the import:
addImportPath(os.dirname(MyScriptPath))

This solution is according to the recommendation, to have an image library in .sikuli, with some naming convention either simply as
"someImage.png"

or as 
someImage = "whatever.png"

in 1st case you say:
click("someImage")

in the 2nd case you use
click(someImage)

The IDE 1.1.0 supports the following:

write
someImage =

click the shot button and take the shot.
The image will be appended and automatically named "someImage.png" so you finally have:

someImage = "someImage.png"

hence fully supporting a naming convention (if you have any ;-)

-- 
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.