#!/usr/bin/env python3 """Edit fields whose labels are exposed only through AT-SPI relations.""" import gi gi.require_version("Gtk", "3.0") gi.require_version("Atk", "1.0") from gi.repository import Atk, Gtk window = Gtk.Window(title="Edit label probe") window.connect("destroy", Gtk.main_quit) box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=8) window.add(box) def field(identifier, labels, name="", password=False): entry = Gtk.Entry() entry.set_text("secret value" if password else "sample value") entry.set_visibility(not password) accessible = entry.get_accessible() accessible.set_name(name) accessible.set_description(identifier) for text in labels: label = Gtk.Label(label=text) box.pack_start(label, False, False, 0) accessible.add_relationship(Atk.RelationType.LABELLED_BY, label.get_accessible()) box.pack_start(entry, False, False, 0) field("related", ["Nickname"]) field("multiple", ["Account", "identifier"]) field("named", ["Other label"], name="Explicit name") field("unlabelled", []) field("protected", ["Password"], password=True) window.show_all() Gtk.main()