Re: dogtail [python-] Closing a window?
- From: Vitezslav Humpa <vhumpa redhat com>
- To: admin lukas-prokop at
- Cc: dogtail-list gnome org
- Subject: Re: dogtail [python-] Closing a window?
- Date: Wed, 13 Aug 2014 12:58:57 +0200
Heya,
My suggestion would be to not use predicates if you need to do some more
custom/regexpy searches etc. The whole concept of predicates was I
presume meant for easy use of the most common stuff and is indeed not
completely great for inheritance.
Instead you can use lambdas or other python constructs to do pretty much
anything, with properties coming from both dogtail and pyatspi.
So generally of course you can do stuff such as this:
def my_func():
return [x in root.applications() if 'woot' in x]
Though you may also stick lambdas to the Node.findChildren() method,
that will recognize the lambda (not being predicate) and will
apply that on all (recursively) children of given node. That's something
we've added recently to easily allow custom searches without having to
deal with Predicate. So you can indeed use re or do anything you wish in
the lambda to filter out the nodes you want.
Example:
node.findChildren(lambda x: x.roleName == 'menu item' and x.showing is
True and re.match(r'...) )
Hope this helps. We generally need to keep the API compatible and try
not make significant changes to the existing core behavior for all the
tests and code out there to keep working with newer dogtail versions, as
far as improvement suggestions go. Adding stuff is a go, of course, and
in that respect patches are welcome.
Vita
On Wed, 2014-08-13 at 00:01 +0200, Lukas Prokop wrote:
I would also like to add an improvement suggestion for dogtail in this
email (I can also open an issue if you think it's worth it):
I want to extend predicates such as
dogtail.predicate.IsAnApplicationNamed. I don't want it to only use plain
strings but also to use regexes or provide my own string normalization
implementation or do any kind of fancy substring search. As it turns out
the design is pretty close to being appropriate, but the problem is that
every predicate instantiates a TranslatableString object and uses the
matchedBy method. So I cannot exchange the instantiation of a different
class without rewriting all Predicate subclasses. Another theoretical
option would be to exchange the stringMatches function, but monkey
patching is not possible. So my point: Can we make predicates more
extendable by sticking to protocols? We would have to move instantiations
outside the class.
Best regards && thanks,
meisterluk
I also don't get the _genCompareFunc method definitions. There should be
no difference if satisfiedByNode is a staticmethod of the class. Or am I
missing something?
[Date Prev][
Date Next] [Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]