← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #260283]: How to create region of image displayed dynamically

 

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

    Status: Needs information => Open

Atul Desai gave more information on the question:
Please find below the code snippet I tried so far.

def handler(e):
    #global ttRegion, regTooltipReady
    ttRegion = Region(find(e.changes))# here you have to evaluate the e.changes
    ttRegion.highlight(1)
    RegToolTipW = ttRegion.getW()
    revenueRegion = Region(ttRegion.find(revenue)) #Dynamically generate Region
    revenueRegion.highlight(1)
    xcoordinate = revenueRegion.getW()    
    ttRegionReady = True
    new = Region(revenueRegion.x+xcoordinate, revenueRegion.y+0, RegToolTipW-xcoordinate, revenueRegion.h+0)
    new.highlight(1)
    val = new.text()
    print "texttest: ",val
    valre = re.search(p,val)
    a = valre.group()
    print "group: ", a
    aa = float(a)
    intTemp = intTemp+aa
    print "temp: ", intTemp
    ##second region
    impressionRegion = Region(ttRegion.find(impression))
    impressionRegion.highlight(1)
    xcoordinateEX = impressionRegion.getW()
    new1 = Region(impressionRegion.x+xcoordinateEX, impressionRegion.y+0, RegToolTipW-xcoordinateEX, impressionRegion.h+0)
    new1.highlight(1)
    valEx = new1.text()
    valueEx = re.search(q,valEx)
    pr = valueEx.group()
    prNew = pr.replace(',','')
    print "groupEx: ", prNew
    ppr = long(prNew)
    newTemp = newTemp+ppr
    print "tempEX: ", newTemp


def func(offSetImage, plotPoints):
    offSetImageRegion = Region(find(offSetImage))
    offSetImageRegion.highlight(1) # highlight matching offset image region on screen.
    # Dynamically generate new Graph Region
    graphRegion = Region(offSetImageRegion.x+20, offSetImageRegion.y-90, offSetImageRegion.w+1050, offSetImageRegion.h+200)
    graphRegion.highlight(1) # highlight matching graph image region on screen.
    #dynamicRegion(offSetImage,plotPoints,20,-90,1050,200)
    counter = 0 # to calculate total plot points.
    intTemp = 0.0
    newTemp = valEx = 0
    for inc in graphRegion.findAll(plotPoints):
        counter += 1
        graphRegion.onChange(handler)
        graphRegion.observe(FOREVER,True)# observe in background
        hover(inc)
        ttRegionReady = False# we use this switch to minimise concurrency problems
        while not ttRegion:# we wait until the handler is visited and has evaluated the region
            wait(1)
    graphRegion.stopObserver()

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