← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #163900]: Function to select image dict.

 

Question #163900 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/163900

    Status: Open => Answered

RaiMan proposed the following answer:
--1: Whatever the specificImageDict is, this is not possible:

def selectGuiMap(theMap):
    guiMap = sikuliWrapper.ImageDict(guiMapSikuli.theMap) # should give a name error

selectGuiMap(specificImageDict)


You say:
I got a file containing various sets of image dictionaries

I guess:
- the file is a some-name.sikuli  
- each dictionary has a systematic name

So if you if you just say in your test script
from some-name import *

all the dictionary names are known in the current context.

so lets assume there are the dictionaries:

highDict
mediumDict
lowDict

you can just say in your test case:

somewhere set res="high" (e.g. in setUp or globally)

currentDict = eval(res+"Dict")

Assuming In your some-name.sikuli there is a function named getImage(currentDict, "image-name")
you can select the needed image.

All this might be wrapped in classes, but this is not really needed.

But if you plan to generalize your solution, then you should revise your
class definitions:

-- attributes (Variables) should be named typeSpecificMoreSpecific
(e.g. a dict in your case: imagesHiRes, an image from this dict imageHires ....)

-- if you want to access instance variables, use getter and setter
methods

Python accepts to use some_object.instance_variable, but if you use
this, it would be a great effort to make changes to the class according
to the class internal dictionary-handling (you could even not rename
it).

so your class should define 
getInstance_variable and setInstance_variable

so you are free to do in your class what you want, without affecting the
outside world.

May be, the solution
https://answers.launchpad.net/sikuli/+question/142149 (comment #7) gives
some advice

You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.