sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #05132
[Question #170365]: NameError: global name 'Rectangle' not defined
New question #170365 on Sikuli:
https://answers.launchpad.net/sikuli/+question/170365
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.dirname(getBundlePath())
if not myPath in sys.path: sys.path.append(myPath)
from testUtility import *
takeScreenshotOfError("myError.jpg")
--------------------------------------------------
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 takeScreenshotOfError(filename):
testResultsPath = "c:\\test\\"
robot = Robot()
theImage = robot.createScreenCapture(Rectangle(Toolkit.getDefaultToolkit().getScreenSize()))
ImageIO.write(theImage, "jpg", File(testResultsPath+filename))
-----------------------------------------
this is the error i get when i run testMain in sikuli IDE
theImage = robot.createScreenCapture(Rectangle(Toolkit.getDefaultToolkit().getScreenSize())) NameError: global name 'Rectangle' is not defined
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
--
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.