Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Get the active window in Gtk using the wnck library.
import wnck
import gtk
import time
if __name__ == '__main__':
screen = wnck.screen_get_default()
while True:
while gtk.events_pending():
print screen.get_active_window().get_name()

This comment has been minimized.

Copy link

ganesshkumar commented Oct 23, 2013

while gtk.events_pending():

Why is this part needed?


This comment has been minimized.

Copy link
Owner Author

adewes commented Oct 24, 2013

It seems that gtk does not update the window title unless you process all pending events first. If you remove the two lines, you should see that the window title will not be updated correctly (at least on my system that's the case). I'm not entirely sure why GTK behaves this way myself, but this hack seems to fix it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.