[2.0.4] addImagePath after runScript() --- fixed in 2.0.5

Asked by Ben Dix on 2021-01-22

Hey Folks,

I build up lots of scripts, working together like a charm 😄
I import different Sikuli Scripts by running the runScript() command and after finishing the script, it returns to my main script and starts another runScript() and so on...

So far I have to use the addImagePath of the main script after every runScript() to get the correct image path again.
My question is, is there a way to define a function, that the image path of the active script will be imported?

something like:

def AutoImportPath():
        addImagePath(of the actual path/sikuli.file of the working script)

is there a way to get the path and name of the working sikuli file?

I searched in python forums and here as well, but can't find a solution how to get this working.
any ideas?

this would clean up my code that much 😄

thx for your help!


Question information

English Edit question
Sikuli Edit question
No assignee Edit question
Last query:
Last reply:
Ben (benvdg) said : #1

If I understand correctly, you want to create a separate function AutoImportPath that will be called from other script, the main goal of the function is to set the ImagePath = to the directory of the calling script.

def AutoImportPath(path):

That you can call from another script, where path = __file__

__file__ should return the path with the name of the script.

Haven't tested to.

Ben Dix (bendix80) said : #2

thx for your reply,

as far is I found out this works only while working directly in a *.py file.
Looks like working with a Sikuli file is the problem...

Launchpad Janitor (janitor) said : #3

This question was expired because it remained in the 'Open' state without activity for the last 15 days.

RaiMan (raimund-hocke) said : #4

is fixed in 2.0.5 (the image path is restored after each runScript - even when nested))