← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #177227]: How to import other scripts

 

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

Description changed to:
*** a summary of the easiest approach

* first see docs: 
http://sikuli.org/docx/globals.html#importing-other-sikuli-scripts-reuse-code-and-images

* place all your .sikuli folders in one place,  
since Sikuli finds imports in the same directory as the main script automagically

e.g.

-- mySikuliSolution
   -- main.sikuli
   -- sub1.sikuli
   -- sub2.sikuli
   -- .... as many as needed

* in each sub
at the beginning of the script place
from sikuli import *

(for the experts: this is only needed if the sub uses Sikuli features)

* in main.sikuli
put at the beginning of the script import statements for the subs
from sub1 import *
from sub2 import *

This makes available all names (variables, functions, classes, ...) from the subs in your main script. Additionally all images contained in the subs will be found automatically (with the import Sikuli updates the image path accordingly)
Have a naming concept, to avoid naming conflicts and overwrites.

* run the main script either in the IDE or from command line

* If you make changes in the subs, you have to restart the IDE 
(for the experts: use reload() as mentioned in the docs)

----------------------------------------------------------------------------------------------------

Hi all,

   Sikuli IDE is very cool, it gives us an intuitive impression on the
images we chosen, however, when I'm taking more modular structure of the
project, and want to move each suit  of images into different resource
folders, and replacing the raw resource string with CONSTANT var in one
python file, I found that Sikuli IDE can't open the .py file, so it's
inconvenience to edit the captured images.

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