How to get list opened windows in PyGTK or GTK in Ubuntu?

前端 未结 6 1925
说谎
说谎 2020-12-30 10:37

How to get list opened windows in PyGTK or GTK or other programming language? in Ubuntu?

edit:

i want get list paths opened directories on

6条回答
  •  無奈伤痛
    2020-12-30 10:57

    Parsing command line output is usually not the best way, you are dependent on that programs output not changing, which could vary from version or platfrom. Here is how to do it using Xlib:

    import Xlib.display
    
    screen = Xlib.display.Display().screen()
    root_win = screen.root
    
    window_names = []
    for window in root_win.query_tree()._data['children']:
        window_name = window.get_wm_name()
        window_names.append(window_name)
    
    print window_names
    

    Note that this list will contain windows that you wouldn't normally classify as 'windows', but that doesn't matter for what you are trying to do.

提交回复
热议问题