Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Your constraint is like saying "I want to build a CD player using only a banana. Please refrain from posting alternative solutions that resort to lasers." GTK can't do that, you're using the wrong tool for the job.</p> <p>Here's an explanation of what a "window" actually means and why your code doesn't work:</p> <p>First off, you need to understand the difference between a <code>gtk.Window</code> and a <code>gtk.gdk.Window</code>. A GTK window is a top level GTK widget that can contain other widgets. It is usually linked to a window on your desktop, but doesn't have to be - in GTK 3 there is an <code>OffscreenWindow</code>.</p> <p>A <em>GDK</em> window, on the other hand, is platform-dependent. On an X desktop it is a thin wrapper around an X window, which is not necessarily a toplevel desktop window. On other systems it exists to abstract away the windowing system. A GDK window receives events, so some GTK non-window widgets have their own GDK windows. "Window" is really a terrible name for these objects, but it was inherited from X and it's probably not going to change.</p> <p>Each GTK process only knows about its <em>own</em> windows. You can get a list of the toplevel GTK windows of <em>your own</em> application using <a href="http://developer.gnome.org/pygtk/stable/class-gtkwindow.html#function-gtk--window-list-toplevels" rel="noreferrer"><code>gtk.window_list_toplevels()</code></a>. Getting the children of these windows should return you the GTK widgets that they contain. However, you can't descend into the widget hierarchy of other processes' windows. For example, what if another process has a window with a child widget that is a custom widget that your process doesn't know about? What should it report as the type of that widget?</p> <p>Getting a list of the toplevel GDK windows with <a href="http://developer.gnome.org/pygtk/stable/class-gdkwindow.html#function-gdk--window-get-toplevels" rel="noreferrer"><code>gtk.gdk.window_get_toplevels()</code></a> is basically the same as getting a list of the toplevel X windows, as far as I understand it. You have no way of knowing what kind of windows they are - they might be the Gnome Panel, or they might be Qt windows, or they might be something else altogether that doesn't correspond with a desktop window.</p> <p>Libwnck (<a href="http://developer.gnome.org/libwnck/stable/getting-started.html" rel="noreferrer">link</a> to the overview of what it does) can get you a list of non-minimized windows, and their titles, but it won't allow you to see inside them. There's no way to do that. Libwnck uses GDK internally, so technically you could do it using GDK, but why would you bother if there's already a library that does that for you? If you really want to do it yourself, look at the libwnck source code.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload