root = gtk.gdk.get_default_root_window()
for id in root.property_get('_NET_CLIENT_LIST')[2]:
    w = gtk.gdk.window_foreign_new(id)
if w:
    pass
How do I get a list of all windows on my gnome2 desktop using pygtk?