← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #211431]: Import sikuli in sikuli ide?

 

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

Brian Redmond posted a new comment:
Here's the way I organize my scripts using Sikuli X 1.0rc3:
In the IDE, create a new script which we'll save as 'mylibrary'.  The IDE creates a folder 'mylibrary.sikuli' and stores 'mylibrary.py' in it with the screenshots you create.  As the first line in this script, put:

from sikuli.Sikuli import *

When you run a script from the IDE, this line is added automatically, but we have to add it ourselves since we will be importing it into another script, not directly executing it from the IDE.  Now, def functions in this file that you want to call from another script.
Create another new script and save as 'mymainscript'.  mylibrary.sikuli and mymainscript.sikuli should share the same parent folder.  In the main script, start with:

import mylibrary
reload(mylibrary)

Now you can call:

mylibrary.myfunction()

The one thing to remember is that you have to make sure to save any
changes you make to the scripts you're importing before running the main
script.  This can be easy to forget when you have several scripts open
in the IDE because there's nothing that indicates if any of them have
unsaved changes.

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