← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #231495]: highlight (and other region methods?) not working with Region subclass

 

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

    Status: Needs information => Open

Matthew Arnold gave more information on the question:
Below is a trimmed version of what I first posted (the relevant code you
asked for). On my computer, on 1.0.0, the two highlighted rectangles are
different.

The bottom cluster of prints exists to show that every property of the
regions, accessed with or without a cast, through the region's
properties or the base Rect's, with getters or without, is the same,
despite how the bottom two regions highlight differently.

=======================================

class MyRegion(Region):
    def __init__(self, region):
        Region.__init__(self, region)
    def debugPrintCoords(self):
        print("x: " + str(self.x) + " y: " + str(self.y) + " w: " + str(self.w) + " h: " + str(self.h))
        return self
    def pad(self,pad,bound):
        self.setRect(self.x - pad, self.y - pad, self.w + (2*pad), self.h + (2*pad))
        self.trimToBounds(bound)
        return self
    def trimToBounds(self, bounds):
        tRect = self.getRect().createIntersection(bounds.getRect())
        self.setW(tRect.width)
        self.setH(tRect.height)
        self.setX(tRect.x)
        self.setY(tRect.y)
        return self

screenRegion = MyRegion(Region(Screen(0).getBounds()))
boundaryRegion = MyRegion(Region(307,71,1122,544)) #for this sandbox, main panel's position is hardcoded
regionToExpand = MyRegion(Region(317,107,22,16))

print(">padding regionToExpand")
regionToExpand.pad(400,boundaryRegion)  

print("RESIZED REGION PROPERTY COMPARISON:")
myRegion = regionToExpand
region = Region(regionToExpand)
myRegionRect = myRegion.getRect()
regionRect = region.getRect()
print("myRegion raw properties: x: " + str(myRegion.x) + " y: " + str(myRegion.y) + " w: " + str(myRegion.w) + " h: " + str(myRegion.h))
print("myRegion raw getters: x: " + str(myRegion.getX()) + " y: " + str(myRegion.getY()) + " w: " + str(myRegion.getW()) + " h: " + str(myRegion.getH()))
print("myRegion getRect properties: x: " + str(myRegionRect.x) + " y: " + str(myRegionRect.y) + " w: " + str(myRegionRect.width) + " h: " + str(myRegionRect.height))
print("myRegion getRect getters: x: " + str(myRegionRect.getX()) + " y: " + str(myRegionRect.getY()) + " w: " + str(myRegionRect.getWidth()) + " h: " + str(myRegionRect.getHeight()))
print("region raw properties: x: " + str(region.x) + " y: " + str(region.y) + " w: " + str(region.w) + " h: " + str(region.h))
print("region raw getters: x: " + str(region.getX()) + " y: " + str(region.getY()) + " w: " + str(region.getW()) + " h: " + str(region.getH()))
print("region getRect properties: x: " + str(regionRect.x) + " y: " + str(regionRect.y) + " w: " + str(regionRect.width) + " h: " + str(regionRect.height))
print("region getRect getters: x: " + str(regionRect.getX()) + " y: " + str(regionRect.getY()) + " w: " + str(regionRect.getWidth()) + " h: " + str(regionRect.getHeight()))

myRegion.highlight(1) #failure point: despite all the other stuff being right, somehow the highlighting reveals different co-ordinates
region.highlight(1)

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