Mulitiple Libraries imports? both image and method types?

Asked by eliteSKL

OS: WIndows XP

i know i only have to wait 2 days but i would like to keep working until then :)

i'm having a hard time figuring out what to do with the "execfile" statement. if i coment one line out and run the script like you normal find the "execfile" statement it works half way... it will run the parts that are not commented out correctly. so i figure i need to make method out of the "execfile" statement

#normal --> #execfile(part1_image_lib + r"\Image_Lib_1280x1024.py")

#Library 1
part1_image_lib = r"path-to-\Image_Lib_1280x1024.sikuli"
def part1_ex(): execfile(part1_image_lib + r"\Image_Lib_1280x1024.py") # if substitue the line below for the normal statement
def part1_bp(): setBundlePath(part1_image_lib)

#Library 2
part2_image_lib = r"path-to-\Image_Lib_1280x1024.sikuli"
def Part2_ex(): execfile(part2_image_lib + r"\Image_Lib_1280x1024.py") #and comment out this one i will run fine for first button.
def F_logon_bp(): setBundlePath(part2_image_lib)

# im trying to do some thing like below from first library
part1_bp() #setbundlepath
part1_ex() #execfile
part1_region.click(part1_screen_okay) #click intended button

# then click this button from another library
part2_bp() #setbundlepath
part2_ex() #execfile
part2_region.click(part2_screen_okay) #click intended button

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
eliteSKL
Solved:
Last query:
Last reply:
Revision history for this message
eliteSKL (camaro70s) said :
#1

okay i figured it out.... lol one of my paths had a typo...
and i have to do this:

def part1_bp(): setBundlePath(part1_image_lib)

then call the bundlepath before i use an image from each library.

part1_bp()
click(image_from_lib1)
part2_bp()
click(image_from_lib2)
part1_bp()
click(image_from_lib1)

i will do the extra writing because it allows me to set up other libraries based around other screen resolutions to allow reuse of my main code, by just changing the BundlePath at top of code.

also i can keep my image libraries separate, which has advantages too.

let me know if i'm wrong. it seem to be working fine so far... in a small scale two button test.

Revision history for this message
eliteSKL (camaro70s) said :
#2

basically my import statements look like this:

#Library 1
part1_image_lib = r"path-to-\Image_Lib_1280x1024.sikuli"
execfile(part1_image_lib + r"\Image_Lib_1280x1024.py")
def part1_bp(): setBundlePath(part1_image_lib)

#Library 2
part2_image_lib = r"path-to-\Image_Lib_1280x1024.sikuli"
execfile(part2_image_lib + r"\Image_Lib_1280x1024.py")
def F_logon_bp(): setBundlePath(part2_image_lib)

Revision history for this message
eliteSKL (camaro70s) said :
#3

this is for image libraries. i'm not exactly sure how it works for method libraries. probably by a similar way.

Revision history for this message
RaiMan (raimund-hocke) said :
#4

Wait a few days and you can use Sikuli X:

import other .sikuli scripts and have access to the contained images automatically.

in addition you might have an image path to access images from wherever you want - even from the internet.

Revision history for this message
RaiMan (raimund-hocke) said :
#5

ok - just saw you know that already ;-)