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

    Status: Open => Answered

RaiMan proposed the following answer:
I now switched to the JetBrains community editions:
IntelliJ IDEA for Java (but it is Python aware too)
PyCharm for Python/Jython scripting

For plain Jython scripting I prefer PyCharm, since it is tailored to
exactly that and hence a bit more straightforward.

But the general approaches are the same in both IDEs.

What is needed to handle the sources in the IDE you have the preferences with 
the project interpreter and the project structure.
For the runtime environment of a script you have to setup a Run configuration 
(menu Run -> Edit Configurations)

At startup (having no project open), you can setup the interpreters to
be selectable for a specific project later.

On Mac (as we are ;-), you have Python 2.7, which should be found and 
configured automatically.
For Jython I have downloaded the installer jar and ran it, so I have my 
runnable Jython (2.7.0) in ~/Applications/Jython.
To configure: 
Preferences -> Project Interpreter -> Button top right with the 3 dots -> Add 
Local
In the file selector navigate to the Jython installation bin/jython and select 
it.
If asked, say ok to everything (it will install pip + ... for Jython)
finally you should have a new line in the interpreter selection field, which 
you might select now as the default.
(mine says: (icon: cup with python) 2.7.0 ( ~/Applications/Jython/bin/jython)

Now it is time to test:
- create a new project (give it a name and select the Jython interpreter (if it 
is not the default already))
- add a new PythonFile to your project (e.g. HelloWorld)
- enter a line: print "hello world"
- -> menu Run -> Run and simply select  the just created PythonFile

PyCharms now has created a Run configuration for you named HelloWorld, which 
you can tailor to your needs:
- -> menu Run -> Edit Configurations

a shortcut are the field and buttons in the toolbar (select the
configuration and click the run button).

These are the specifics for SikuliX 1.1.x:

- at runtime the sikulixapi.jar must be on classpath.
I recommend to run a setup with options 2 and 3 to get it (do not use the 
pre-setup stuff - no guarantee)
In the run configuration add an entry to the environment variables:
as name: CLASSPATH
as value: <path to>/sikulixapi.jar

- to make a script SikuliX aware add this as the first 2 lines to your main 
script:
import org.sikuli.script.SikulixForJython
from sikuli import *

as a test add line
popup("hello world")

just ignore the the syntax check errors and run it.

You should get your popup.

This first run has also adjusted the bundled Jython support in the 
SikulixAppData area:
/Users/<your name>/Library/Application Support/Sikulix/Lib

To make your source handling a bit nice now, you might add this Lib folder in 
the Preferences -> Project Structure as a new Content Root.
If you do that, you will get a few less syntax error detections in the source 
view, but generally it does not help much, since most of the API is hidden or 
only dynamically available at runtime.
means: currently you will have nearly all SikuliX specific features mentioned 
as syntax errors.
You either have to ignore them or switch them of with the respective options.
It will be a bit better with the final 1.1.1
For version 2 it is planned, that you will have ALL PUBLIC SikuliX features 
available for lookup including docs in the source view of a Python IDE like 
PyCharm.

-- 
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.

_______________________________________________
Mailing list: https://launchpad.net/~sikuli-driver
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~sikuli-driver
More help   : https://help.launchpad.net/ListHelp

Reply via email to