← Back to team overview

sikuli-driver team mailing list archive

[Question #247820]: Problem calling functions in nested imports

 

New question #247820 on Sikuli:
https://answers.launchpad.net/sikuli/+question/247820

Hello,

I'm new to Sikuli and python and I'm trying to import functions in my script but it doesn't work the way I want it to.
Hopefully someone can help me out.

I use the IDE and all .py files start with "from sikuli import * "
This is the structure I have for my scripts, my images and my functions:

|_Program I want to test
   | 
   |_Functions
   |  |_AllFunctions.sikuli
   |  |_Function1.sikuli
   |  |  |_HandyFunction1()
   |  | 
   |  |_Function2.sikuli
   |  |  |_HandyFunction2()
   |
   |_Images
   |  |_AllImages.sikuli
   |  |_ImagesModule1.sikuli
   |  |_ImagesModule2.sikuli
   |
   |_Scripts
      |_Script1.sikuli
      |_Script2.sikuli

AllImages.sikuli imports all ImagesModule.sikuli and when I want to use an image in one of my scripts I add the images folder to my sys.path and I import AllImages. This gives my script access to all the images without having to import each individual imagemodule in my script.

I'm trying to do the same thing for functions by importing all  functions into AllFunctions.sikuli, adding the functions folder to my sys.path and importing AllFunctions into my script but this time it doesn't work.
When I use:
import AllFunctions as af
af.HandyFunction1()
I get an error: AttributeError ( 'module' object has no attribute 'HandyFunction' )

But when I use:
import Function1 as fone
fone.HandyFunction1()
Everything works fine.

How can I get this to work?

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