user3085513
user3085513

Reputation: 99

how to get Gtkwindow instead of GdkWindow

I want to get gdkwindow, I know there are method listing all gdk window opened in the desktop, But how to Get a GtkWindow? I know GtkWindow has a property gdkwindow, but How to Get GtkWindow by GdkWindow?

Upvotes: 1

Views: 1187

Answers (1)

ohmu
ohmu

Reputation: 19760

Without more context I can't really answer your question any better, but try using gtk.window_list_toplevels(). It will return the list of all top-level GTK windows for the current process.

Here's how you would devise a method to return the corresponding top-level GTK window from a GDK window XID.

def find_gtk_window(xid):
    for gtk_window in gtk.window_list_toplevels():
        if gtk_window.window.xid == xid:
            return gtk_window

But, if you want to list all GTK windows of other processes, then that's not (easily) possible. An answer to How do I get a list of all windows on my gnome2 desktop using pygtk? describes the situtation pretty well.

Upvotes: 2

Related Questions