-
Notifications
You must be signed in to change notification settings - Fork 233
Jython in IDEs like Eclipse or running it from commandline
Run setup with option 2 producing a sikulixapi.jar
Read about new central folder SikulixAppData
When using Jython e.g. in Eclipse or standalone, the following setup is the easiest and most effective:
-
have a reference to sikulixapi.jar in your project's Java class path
(in your IDE's project's external libraries or simply in Java class path with other setups)
(do not use sikulix.jar in this case, since the contained Jython might collide with the Jython you want to use)
in your main script at the beginning add:
import org.sikuli.script.SikulixForJython
from sikuli import *
(do not use from sikuli.Sikuli import *
any longer)
The first entry is new and adds the path of the Sikuli Jython API to the Python sys.path at runtime (no need to add it yourself, but you might ;-).
from sikuli import *
is also needed in every module, that is imported and uses Sikuli features.
To support Jython code completion in the editor of IDE's , you usually need a reference to the Jython sources of Sikuli in your project setup. To no longer have the need to extract the stuff from the jar yourself (Eclipse/PyDev still does not accept references to folders inside of jars), Sikuli will export to the folder SikulixAppData/Lib at runtime.
To support code completion just add to your setup:
<SikulixAppData>/Lib
Be aware Since the undotted functions like click()
are only at runtime known to the Jython interpreter (dynamically bound to the object SCREEN being Screen(0)), Eclipse will always tell you, that the name click is unknown - no solution for that with any Eclipse settings.
You simply have to avoid that:
scr = Screen(0) # once at the beginning
# and later use
scr.click()