pyatspi2

:06.04.2023
  Twitter   F******k   VKontakte   Telegram   Mastodon

PyAtSpi2Example.

AT-SPI , , , / . AT-SPI GNU/Linux ISO/IEC 13066.

, AT-SPI , pyatspi, AT-SPI python. pyatspi . , , , (, Accerciser), (, Orca, ).

GNU/Linux pyatspi. , Ubuntu pyatspi root:

apt install python-pyatspi

AT-SPI

, , () , , . (assistive technology) , (accessibility three). AT-SPI () AT-SPI, , API pyatspi.

, pyatspi:

import pyatspi

:

desktop = pyatspi.Registry.getDesktop(0)
for application in desktop:
print(application.name)

, :

a = desktop[0]
print(a.name)
for o in a:
print(o)

( , ):

gucharmap
[frame | Character Map]

, gucharmap, (), Character Map. , AT-SPI, (accessibility object).

, :

for o in a:
print(o.role, o.name)

:


 Character Map

, () .

:

frame = a[0]
for o in frame:
print(o)

:

[panel | ]
[menu bar | ]

, .

:

panel = frame[0]
for o in panel:
print(o)

:

[status bar | U+10000 LINEAR B SYLLABLE B008 A]
[text | test]
[push button | Copy]
[label | Text to copy:]
[split pane | ]
[filler | Font]

, , . , , :

t = panel[1]
l = panel[3]
print(t.role)
print(l.role)
t_text = t.queryText()
l_text = l.queryText()

.: pydoc pyatspi.Text

print(t_text.caretOffset)
print(l_text.caretOffset)

, .name , : , , , , .name , .

:

p = t.parent
print(p == panel)

, AT-SPI, , ...

AT-SPI , . ( , , ..) ( , ..).

, (), :

def f(e):
print(e.source, " got caret ", e.detail1)
pyatspi.Registry.registerEventListener(f, "object:text-caret-moved")
pyatspi.Registry.start()

:

[text | ] got caret 2
[text | ] got caret 1
[text | ] got caret 0
[entry | ] got caret 23
[entry | ] got caret 24
[entry | ] got caret 25

, , .

:

def f(e):
print(e.source, " got focus " if e.detail1 else " lost focus")
pyatspi.Registry.registerEventListener(f, "object:state-changed:focused")
pyatspi.Registry.start()

.

, object:state-changed .. XML- dbus: https://github.com/GNOME/at-spi2-core/blob/master/xml/Event.xml. , xml Object StateChanged dbus "object:state-changed" pyatspi2.



, .
: ©  ,  2004-2024