sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #19291
[Bug 1201927] Re: 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.
** Changed in: sikuli
Status: New => In Progress
** Changed in: sikuli
Importance: Undecided => High
** Changed in: sikuli
Assignee: (unassigned) => RaiMan (raimund-hocke)
** Changed in: sikuli
Milestone: None => 1.1.0
** Summary changed:
- Extend region methods do not return a complete Region object
+ [1.0] Extend region methods do not return a complete Region object
--
You received this bug notification because you are a member of Sikuli
Drivers, which is subscribed to Sikuli.
https://bugs.launchpad.net/bugs/1201927
Title:
[1.0] Extend region methods do not return a complete Region object
Status in Sikuli:
In Progress
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(str(self))
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 "regionCenterScreen: %s" % regionCenterScreen.__class__.__name__
# 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 "regionCenterScreen.left(5): %s" % regionCenterScreen.left(5).__class__.__name__
# 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(regionCenterScreen)) - set(dir(regionCenterScreen.nearby(5)))
# This works
regionCenterScreen.monkey_patch()
# This throws AttributeError
regionCenterScreen.left(5).monkey_patch()
# This works
Region(regionCenterScreen.left(5)).monkey_patch()
</pre>
To manage notifications about this bug go to:
https://bugs.launchpad.net/sikuli/+bug/1201927/+subscriptions
References