← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #688984]: IDE: imported helper.py files are not automatically reimported if changed

 

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

RaiMan proposed the following answer:
works with SikuliX 2.0.x

----------------------------- main.py
# this is a solution with plain .py files
# this is main.py

# add the path to import images.py
imagePath = makePath(getBundlePath(), "images")
if not imagePath in sys.path: sys.path.append(imagePath)

# add the path to ImagePath to access the images
ImagePath.add(imagePath)

# images.py is in subfolder images
# which is in same folder as main.py
import images
reload(images)
from images import *

# helper.py is in same folder as main.py
import helper
reload(helper)
from helper import *

# this would/should be sufficient
# if the auto-re-import also works with plain .py files
import images
from images import *
import helper
from helper import *

print "from main"
for e in sys.path: print e

callMe() # in helper

# all three print: image1.png: (130x31)
print Image.create(image1)
print Image.create("image1")
print Image.create("image1.png")

# as long as image2 is not defined in images.py
#this gives: [error] NameError ( name 'image2' is not defined )
#print Image.create(image2) # uncomment to use

#this gives image2.png: (0x0)
#[error] ImagePath: find: not there: image2.png
#print Image.create("image2") # uncomment to use

---------------------------- helper .py
from sikuli import *

def callMe():
  print "from help"

--------------------------- folder images
image1.png

# images.py
image1 = "image1.png"

#if uncommented, image2 will be known
#image2 = image1

-- 
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.