Я пишу приложение, используя Python и GTK3. Это приложение откроет экземпляры других приложений, таких как GEdit. Теперь я также хотел бы, чтобы мое приложение могло фокусировать каждый из этих экземпляров. Мое приложение специально предназначено для Unity.
Как мне это сделать?
Хорошо, получается, что переключать окна очень легко.
#!/usr/bin/env python # This code will focus the window with integer id 67108870 # Tips: you can get that with xwininfo -int # wnck is used for window management import wnck # time is needed because wnck requires it import time # Get information about windows, workspaces, etc from the X server wnck.screen_get_default() # Get a reference to the window we want to focus # by providing an integer xid the_win = wnck.window_get(67108870) # activate the window, providing an int timestamp the_win.activate(int(time.time())
Я улучшу этот ответ по мере изучения.