← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #166826]: IDE changes png file paths

 

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

    Status: Open => Answered

RaiMan proposed the following answer:
--1.
if you want to use path's for images, you have to use absolute paths. 

--2.
if you want to refer a directory in the same directory as your script:
import os
imageDir = os.path.join(os.path.dirname(getBundlePath()), "images")
...
click(os.path.join(imageDir), "test001c.png"))

--3.
the most elegant and flexible solution is to have all images in one images.sikuli and just import this.
This allows to use variables for images (with a naming convention) or sets of images in lists or dictionaries.
look: http://sikuli.org/docx/globals.html#importing-other-sikuli-scripts-reuse-code-and-images

images.sikuli:
img1 = "some-image.png"
# more images

main.sikuli
import os
dir = os.path.dirname(getBundlePath())
if not dir in sys.path: path.append(dir)
from images import *
click(img1)

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