Bugzilla – Attachment 188846 Details for
Bug 35654
A writer document doesn't implement the Collection interface of AT-SPI.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
Get all the tables in a document via collection
tables-collection.py (text/x-python), 1.59 KB, created by
Joanmarie Diggs
on 2023-08-08 11:57:47 UTC
(
hide
)
Description:
Get all the tables in a document via collection
Filename:
MIME Type:
Creator:
Joanmarie Diggs
Created:
2023-08-08 11:57:47 UTC
Size:
1.59 KB
patch
obsolete
>#!/usr/bin/python3 > >import sys > >import gi >gi.require_version("Atspi", "2.0") >from gi.repository import Atspi > >def find_with_role(root, role, max_matches): > rule = Atspi.MatchRule.new( > Atspi.StateSet(), Atspi.CollectionMatchType.ALL, > {}, Atspi.CollectionMatchType.ALL, # object attributes > [role], Atspi.CollectionMatchType.ANY, > [], Atspi.CollectionMatchType.ALL, # interfaces > invert=False) > return Atspi.Collection.get_matches( > root, rule, Atspi.CollectionSortOrder.CANONICAL, max_matches, True) > >def on_event(e): > if e.type == "object:state-changed:focused" \ > and e.detail1 and Atspi.Accessible.get_role(e.source) == Atspi.Role.TERMINAL: > print("Exiting.") > stop() > > if Atspi.Accessible.get_role(e.source) != Atspi.Role.FRAME: > return > > print(f"\n\nSearching in {Atspi.Accessible.get_name(e.source)} {Atspi.Accessible.get_role_name(e.source)}") > try: > objs = find_with_role(e.source, Atspi.Role.TABLE, 0) > except Exception as error: > print(f"\nEXCEPTION: {error}") > stop() > > if not objs: > print("No match found") > else: > for obj in objs: > print(f"Found {Atspi.Accessible.get_name(obj)} {Atspi.Accessible.get_role_name(obj)}") > >def stop(): > listener.deregister("window:activate") > Atspi.event_quit() > >listener = Atspi.EventListener.new(on_event) >listener.register("window:activate") # We search in newly-activated windows. >listener.register("object:state-changed:focused") # We exit when a terminal gets focus. >print("Return focus to your terminal to exit") >Atspi.event_main() >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 35654
:
44846
| 188846 |
188847