gtk: set active window

不羁岁月 提交于 2019-12-08 02:27:44

问题


I have a gtk.Window. How do I set it to be the active window? I can call is_active() to see whether it already is, but I don't see where to make it active.

Bonus points: given a gtk.Widget, how do I make the window it is a part of the active window?


回答1:


Ah thanks to this thread, the answer is to call gtk.Window.present().




回答2:


if W is a gtk.Window:

import wnck
wnck.window_get(W.window.xid).activate()



回答3:


Here's what worked for me (thanks Dan D for pointing out wnck)

def activate(window):
    screen = wnck.screen_get_default()
    screen.force_update()
    wnckwin = [win for win in screen.get_windows() if win.get_xid() == window.window.xid][0]
    wnckwin.activate(gtk.gdk.x11_get_server_time(window.window))



回答4:


You can also use gtk.Dialog.run (if it's a Dialog) aditional to gtk.Window.present



来源:https://stackoverflow.com/questions/5393185/gtk-set-active-window

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!