← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #161008]: can i share images across scripts?

 

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

Calle Rundgren proposed the following answer:
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:

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