Re: dogtail-devel hypertext / hyperlink objects
- From: Zack Cerza <zcerza redhat com>
- Cc: dogtail-devel-list gnome org
- Subject: Re: dogtail-devel hypertext / hyperlink objects
- Date: Mon, 17 Oct 2005 18:04:41 -0400
Marius Andreiana wrote:
> Hi,
>
> As it's my first post here, let me start with congratulations for
> Dogtail, it's a great application!
Thanks :)
> I'm trying to get links on a webpage as separate objects. Now separate
> links are seen as a text string, e.g.
> Node roleName='text' name='' description='no description'
> text='Google.ro offered in: Romana magyar Deutsch Advertising Programs
> - About Google - Go to Google.com'
>
>
> I've implemented Hypertext class support to pyspi (sent patch to
> pyspi-list, I'll followup with Hyperlink) and added this to tree.py
> 249c249
> < contained = ('__accessible', '__action', '__component',
> '__text', '__editableText')
> ---
>
>> contained = ('__accessible', '__action', '__component',
>
> '__text', '__editableText', '__hypertext')
> 286a287,291
>
>> # Swallow the Hypertext object, if it exists
>> hypertext = self.__accessible.getHypertext()
>> if hypertext is not None:
>> self.__hypertext = hypertext
>>
>
> 391a397,398
>
>> elif attr == "hypertext":
>> return self.__hypertext.getHypertext()
Here, you're effectively doing:
self.__accessible.getHypertext().getHypertext() - which won't work.
The whole Hypertext/Hyperlink will probably have to be implemented in
tree.py similar to the way actions work:
class Hyperlink:
def __init__(self, node, hyperlink, index):
self.node = node
[...]
def __getattr__(self, attr):
if attr == "URI":
return self.__hyperlink.getURI()
[...]
else: raise AttributeError, attr
and inside Node we'll have:
def __getattr__(self, attr):
[...]
elif attr == "hyperlinks":
hyperlinks = []
for i in xrange(self.__hypertext.getNLinks()):
hyperlinks.append(Hyperlink(self, self.__hyperlink, i)
if hyperlinks: return hyperlinks
else: raise AttributeError, attr
So, we don't need to actually expose any Hypertext objects via tree.py -
we'll just skip straight to the Hyperlinks.
> However, the dump of Epiphany tab is exactly the same as before, no
> Hypertext object. What should I do to get the links as objects (and
> click on them from Dogtail) ?
Well, as you can see, there's still a bit more work to do. I guess I
just did most of the necessary tree.py work, though. :)
Even once that is done, you won't see any objects with a roleName of
hyper*. Their roleName will just be text, since Accessible*[Tt]ext
inherit from AccessibleText. This is just the way AT-SPI works.
> And another issue, why are the text entries in web pages (<input
> type='text'...>) have the roleName "text" instead of "editableText" in
> node dump? Would make it easier to find, I don't know how to get the
> text entry in this dump:
This is for the same reason as above. If a Node with a roleName of
'text' is editable, you can just do:
node.text = 'foo'
and maybe handle the exception that will be raised in cast it's not
editable.
Yeah, this is tricky. But I couldn't find a more sane way to implement
it, given AT-SPI's own level of sanity :)
> Thanks in advance for enlightenment :)
No problem at all.
Thanks,
Zack
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]