can i share images across scripts?

Asked by Divya Sunkam

I started using sikuli a week back and wanted to know if I can handle these scenarios

1. Store images in a common repository/folder and create multiple scripts to access the images from this directory.
I have kept all the images under a .sikuli file(say images.sikuli) and done "import images" in other sikuli files.
Now, I want to access the images from the images.sikuli without having to give the entire path of the image.

2. If i have multiple images like delete button with either white or grey background can I have a directory called delete button and put all the different images of delete button within this directory and make the script look for the directory instead of the image ?

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

-- at 1:
have a look at doc: http://sikuli.org/docx/globals.html#importing-other-sikuli-scripts-reuse-code-and-images
just import the .sikuli containing the images and they will be available.

-- at 2:
not a feature. you always have to specify an image file.

Revision history for this message
Calle Rundgren (c-rundgren) said :
#2

I think it is a great solution to store methods in libraries aswell as images. Then you can easily access universal methods which can be used in multiple scripts instead of rewrite the samt method.

In order to import a library I use this mthod RaiMan shown me one time:

import os

Path = input("Input path to GUI library")
Name= input("Input filename for the .sikuli file")
thePath = Path
theLib = FileName
theLibSikuli = os.path.join(thePath, theLib+".sikuli")
theLibScript = os.path.join(theLibSikuli, theLib+".py")
execfile(theLibScript)
setBundlePath(theLibSikuli)

---------------------------------------------------------
To define a method in the library you use this code:

def testMethod():
    click(testImage)
    wait(3)
---------------------------------------------------------
In the bottom level script file you simply call the method
like this: testMethod()
and the script will perform the task the method include.
---------------------------------------------------------
Read more about using libraris in this thread: https://answers.launchpad.net/sikuli/+question/155898
And in this one you can se some more examples of defining methods:

Revision history for this message
Calle Rundgren (c-rundgren) said :
#3

Can you help with this problem?

Provide an answer of your own, or ask Divya Sunkam for more information if necessary.

To post a message you must log in.