[check] Extend region methods do not return a complete Region object
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
SikuliX |
In Progress
|
Medium
|
RaiMan |
Bug Description
Sikuli 1.0.0 Win7-64
I have a number of methods that I have monkey patched on the Region and Match objects to extend the API in python and it generally works great. The one issue is that above(), below(), left(), right(), nearby() and offset() do not return a proper Region object. I think example code is the easiest way to explain, let me know if you have questions:
<pre>
# define function to be added to Region object as a new method
def monkey_patch(self):
popup(
return self
# Add the method to the Region object
Region.monkey_patch = monkey_patch
# Create a region object at the center of the screen
regionCenterScreen = Region(SCREEN.w/2, SCREEN.h/2, 5, 5)
# printing the class name shows that this is a Region object
print "regionCenterSc
# printing the class name of the object returned by the left method is also a Region so it should have the same methods and
# attributes as the original object
print "regionCenterSc
# print the difference between the method/attributes of the two objects
# This should be an empty set, but instead it's actually pretty long
print set(dir(
# This works
regionCenterScr
# This throws AttributeError
regionCenterScr
# This works
Region(
</pre>
tags: | added: fkt-region |
Changed in sikuli: | |
milestone: | 1.1.0 → 1.2.0 |
Changed in sikuli: | |
milestone: | 2.0.0 → 2.1.0 |
importance: | High → Medium |
summary: |
- [1.0] Extend region methods do not return a complete Region object + [check] Extend region methods do not return a complete Region object |
This is a general known (admitted: ugly ;-) problem with the API implementation, which for Region is to 98% is on the Java level.
The only chance, tobe sure, to always get a Jython level region object returned is to cast:
jReg = Region( some_region_ created_ before)
I am working on a solution for version 1.1, that assures, that every Region created in a Jython environment is always a Jython level region object.