sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #10627
Re: [Question #197294]: Can Sikuli Methods be Overridden?
Question #197294 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/197294
RaiMan proposed the following answer:
@ (j-the-k)
principally ok, but the sikuli.Sikuli does not contain the click() and other Region methods.
They are either in sikuli.Region or in the Java Region class.
And most of the methods are instance methods and not class methods.
So your click() suggestion will only work for unqualified usages, which
search on the whole screen.
reg.click() will still use the Region method.
*** Depending on what you want to achieve (e.g. some wrapping), you have
to use something like:
class myRegion (Region):
def __init__(self, reg):
self.theReg = reg
def click(self):
# some code
self.theReg.click()
# some code
usage e.g.
reg = find(something)
myReg(reg).click()
This would help in the mentioned situation (track timing).
The problem in Python/Jython is, that you might well subclass, but not selectively override on the method level (as is possible e.g. in JRuby) (with the normal language features).
There are other possibilities, if you step down to the Java level (which can be done from the Sikuli script level).
*** Another possibility for the time tracking issue:
def xt(cmd):
# timer start
ret = eval(cmd)
# timer end
usage e.g.
xt('click(image)')
--
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.