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

前端 未结 6 1950
说谎
说谎 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 11:10

    For whatever reason, I can't post a comment, but I'd like to add this as an addendum to Sandy's answer.

    Here's a chunk of code that lists the current windows on the console:

    import pygtk
    pygtk.require('2.0')
    import gtk, wnck
    
    if __name__ == "__main__":
        default = wnck.screen_get_default()
    
        while gtk.events_pending():
            gtk.main_iteration(False)
    
        window_list = default.get_windows()
        if len(window_list) == 0:
            print "No Windows Found"
        for win in window_list:
            if win.is_active():
                print '***' + win.get_name()
            else:
                print win.get_name()
    

    Thanks Sandy!

提交回复
热议问题