sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #02509
Re: [Question #155898]: Help with library
Question #155898 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/155898
Status: Open => Answered
RaiMan proposed the following answer:
Since you are new, I guess you are using X-1.0rc2.
If yes, the solution you found is still valid, but too complicated.
We have a much better solution now:
see docs: http://sikuli.org/docx/globals.html#importing-other-sikuli-scripts-reuse-code-and-images
-- backslashes in Windows
if you use normal strings ("some text"), you have to use double \
but you can use raw strings with r"some text", where you can use one \
your case using raw strings: (this way, execfile() should work)
libpath = r"C:\Documents and Settings\Administratör\Skrivbord" + r"\test_lib.sikuli"
execfile(libpath + r"\test_lib.py")
setBundlePath(libpath)
click_start()
but there is a more elegant method to handle path's:
import os
thePath = r"C:\Documents and Settings\Administratör\Skrivbord"
theLib = "test_lib"
theLibSikuli = os.path.join(thePath, theLib+".sikuli")
theLibScript = os.path.join(theLibSikuli, theLib+".py")
execfile(theLibScript)
setBundlePath(theLibSikuli)
Nevertheless I recommend to use the import feature, since it handles the
images as well.
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.