SikuliX cannot call makeOpts()

211 views Asked by At

I am working on sikulixide-2.0.5 on windows. Now I would like to utilize user properties write/read functions to implement persistence of application parameters, So that I am learning as the part of reference shown : https://sikulix-2014.readthedocs.io/en/latest/globals.html#saveOpts

The question is , whatever I call any persistence-related API with fix term of Opt , for example makeOpts() , the engine would keep answer me following error, How do I get it works?

[error] AttributeError ( 'org.sikuli.script.support.RunTime' object has no attribute 'makeOpts' )

reference code here , pretty simple :

from sikuli import *

def trialOpts():
    obj = makeOpts()
    return

trialOpts()

As contrast , other kind API like click(), find() are working fine without AttributeError message , which means the main engine of Sikuli is exactly running.

Since these are native API of Sikuli , as my understanding , it should not have to import any modules? To make sure of that , I studied bit source codes of Sikuli on Github , the APIs with term Opt were exactly defined there in Sikuli.py :

enter image description here

By far I am running out clues. Please can you help.

2

There are 2 answers

3
Curtis On BEST ANSWER

Those "*Opts" convenience methods seem to not exist in the 2.0.5 release. It looks like they were refactored out of existence.

To see what those methods do (and potentially recreate them in jython), see:

https://www.javatips.net/api/SikuliX-2014-master/API/src/main/java/org/sikuli/script/RunTime.java

Additionally, it looks like the github project has the code if you pull a pre-2.0.0 tag:

https://github.com/RaiMan/SikuliX1

0
Curtis On

I took another look into the most recent release code and there are alternative preferences handling methods available (see: org.sikuli.basics.PreferencesUser)

from sikuli import *
from org.sikuli.basics import PreferencesUser

def trialOpts():
    obj = PreferencesUser.get()
    obj.put("foo","bar")
    print obj.get("foo","bart")
    return

trialOpts()