#!/usr/bin/python

import pyatspi

def listener(e):
    activeDescendant = e.any_data
    allChildren = [x for x in activeDescendant]
    showingChildren = list(filter(lambda x: x.getState().contains(pyatspi.STATE_SHOWING), allChildren))
    print("\n    All: %s" % "".join(map(str, allChildren)))
    print("Showing: %s" % "".join(map(str, showingChildren)))

pyatspi.Registry.registerEventListener(listener, "object:active-descendant-changed")
pyatspi.Registry.start()
