← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #205675]: How to call a function/module in a driver script from another sikuli script?

 

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

    Status: Open => Answered

RaiMan proposed the following answer:
--- modules, that are imported ...
are processed, when imported the first time in a python session. This is mainly used, to process some initialization code.
This means, that every code, that runs, when you run the module standalone is processed, when it is imported.
This usually is blocked, by checking, whether the module is imported or runs as main.

In your case, you simply should delete or comment out your "test" code
from  MyFile.sikuli

# MyFile.sikuli
from sikuli import *

class NewUserFlow():
   def TutorialOne(self):
      pass
   def TutorialTwo(self):
      pass
   def TutorialThree(self):
      pass
"""
test = NewUserFlow()
test.TutorialOne()
test.TutorialTwo()
test.TutorialThree()
"""

the usage in your driver script:
# MyDriver.Sikuli
import MyFile.sikuli
flow = MyFile.NewUserFlow()
flow.TutorialTwo()

BTW:
- with Sikuli X:
from sikuli import *
- and it is only needed in imported modules

-- 
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.