sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #03673
Re: [Question #162999]: Using dictionaries
Question #162999 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/162999
Status: Open => Answered
RaiMan proposed the following answer:
- inside a class definition the instance variables (in your case images) have to be qualified with self.
- the parameter images does not make sense with __init__()
class imageDictWrapper():
def __init__(self, imageSet = "HiRes"):
self.images = theImageDict
def getImage(self, imageName):
return self.images[imageName]
--- I would do your approach this way:
-- content of imageDictWrapper.sikuli
from sikuli.Sikuli import *
class imageDict():
def __init__(self, imageSet):
self.images = imageSet
def getImage(self, imageName):
return self.images[imageName]
-- main script:
sikuliPath = r"c:\sikuli"
if not sikuliPath in sys.path: sys.path.append(sikuliPath)
import imagesAllRes
import imageDictWrapper
imgSet = imageDictWrapper.imageDict(theImageDictHiRes)
click(imgSet.getImage("openButton"))
imagesAllRes.sikuli contains images for all resolutions AND the
respective dictionaries containing the references to the images of a
specific resolution.
So you have full control in your workflow, which of the dict's you want
to use (theImageDictHiRes in this case).
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.