Search code examples
pythonwindowwnck

python wnck.window_get() works from conlose but not from module


The code below works if I type it in just now opened python console, but not if I run it from file (there are no other code in this file)

import wnck
screen = wnck.screen_get_default()
wnck.window_get(58720313L).activate(9999999999)

Solution

  • It's because there are events in the queue; the StackOverflow question python wnck not returning any data until after a pdb.set_trace() explains this. You just have to wait for the window list to fill up; when it is run fron the console, I believe Python empties the queue, but when you're running a file, you have to run the gtk iteration functions.