Name Error using Java classes in imported script --- workaround
***** workaround
when importing other .sikuli, use Java's fully qualified package names in the imported modules.
see comment #2 below
If you decide to use the direct import of the contained .py files, you have to import each class package like:
from some.java.package import Class
so you can use later
x = Class()
see comment #4 below
-------
Hi,
I created a utility module that will assist me in taking screenshots when my script runs into an error, but I'm getting "NameError: global name 'Rectangle' not defined" and am not sure why.
Here are my functions:
-------
my file directory is this
-------
./testMain
./testUtility
-------
testMain contains
-------
import os
myPath = os.path.
if not myPath in sys.path: sys.path.
from testUtility import *
takeScreenshotO
-------
testUtility contains
-------
from java.awt import Robot
from java.awt import Toolkit
from java.awt import Rectangle
from java.io import File
from javax.imageio import ImageIO
def takeScreenshotO
testResultsPath = "c:\\test\\"
robot = Robot()
theImage = robot.createScr
ImageIO.
-------
this is the error i get when i run testMain in sikuli IDE
theImage = robot.createScr
can anyone help me with this? the code works when when it's all contained in one file, but i need it to be modular so other sikuli scripts can use the screenshot function.
thanks
Question information
- Language:
- English Edit question
- Status:
- Solved
- For:
- SikuliX Edit question
- Assignee:
- No assignee Edit question
- Solved by:
- Benny Phanichkul
- Solved:
- Last query:
- Last reply: