PyCharm is highlighting code in red while I'm trying to use sikulixapi.jar to write Jython scripts

Asked by zhenya on 2018-08-03

Hello! I'm trying to set up Sikuli for Jython autotests writing in PyCharm.
Some basic scripts are working for now, but there is some unexpected behavior of PyCharm.

What I've done before:
1) installed PyCharm
2) installed Jython (and set it as an interperter in PyCharm)
3) downloaded sikulixapi.jar
4) created project with .py file within (in this .py file's configuration I've created "CLASSPATH" environment variable with sikulixapi.jar filepath as a value)

.py script looks like this:

import org.sikuli.script.SikulixForJython
from sikuli import *

click ("button.jpg")

unexpected behavior:
1) PyCharm doesn't give autocomplete advices, like when I've wrote "e" -> "exists". Does it really should be so?
2) PyCharm highlights some parts of code in red with given suggestions (but why?):
"import org.sikuli.script.SikulixForJython" -> no module named "org"
"from sikuli import *" -> unresolved reference "sikuli"
"click ("button.jpg")" -> unresolved reference "click"

my environment:
Mac OS Sierra
jython 2.7.1

Question information

Language:
English Edit question
Status:
Answered
For:
Sikuli Edit question
Assignee:
No assignee Edit question
Last query:
2018-08-03
Last reply:
2018-08-04
RaiMan (raimund-hocke) said : #1

--- downloaded sikulixapi.jar
a valid sikulixapi.jar MUST be created using setup (recommended 1.1.3 nightly)

--- autocomplete
... does not work for the undotted methods like exists, click, ..., because these references are only created at script runtime.

for autocomplete you have to use the dotted versions like so:
scr = Screen(0)
scr.click(someImage)

Can you help with this problem?

Provide an answer of your own, or ask zhenya for more information if necessary.

To post a message you must log in.