how to call/import a function in one script to another script

Asked by Santhosh Motamarry

i have a global function in one of my script and i need to call/import into one of my another script. could you please let me know regarding it.

Question information

Language:
English Edit question
Status:
Answered
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#1

the basic template is (it is Sikuli's extension of the standard Python import):

*** main.sikuli
from sub import *
# using/call
myFunction()

*** sub.sikuli
# mandatory if Sikuli features are used here
from sikuli import *

def myFunction():
     popup("hello from myFunction")

this works as is, if the two scripts are in the same directory.
all images in main and sub are accessible automagically.

for more information: http://sikuli.org/docx/globals.html#importing-other-sikuli-scripts-reuse-code-and-images

Can you help with this problem?

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

To post a message you must log in.