如何真正将窗口置于所有其他窗口之上——Linux PyGTK
我正在尝试制作一个保留在 lxpanel 之上的窗口。
我加载了窗口,使用
import gtk
myWindow = gtk.Window()
myWindow.set_keep_above(True)
myWindow.show_all()
This 确实给了我一个停留在顶部的窗口,它甚至在拖动时设法在 LXpanel 上滑动。当单击其他窗口时,它甚至会保持在顶部,但是当我单击 LXpanel 本身时,lxpanel 会跳到顶部,将我的窗口推到其后面。我怎样才能让这个窗口真正保持在最上面?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
此行为由窗口管理器控制,您对此无能为力。
(在我的测试中,尽管 EWMH 推荐,但也许您的 WM 不这样做。)
但是,有一个非常有限的解决方法:如果您假设用户永远不会有多个停靠/面板,您可以将窗口设置为 transient 对于该停靠窗口。通常(同样,取决于窗口管理器)这将使您的窗口保持在停靠窗口之上。
更新:在X11中,即使它们不在同一进程中,您也可以设置瞬态窗口。我发现的最简单的方法是使用 libwnck 获取面板窗口的 XID,然后使用 gdk_window_foreign_new。当然,这在非 X 系统中不起作用。
This behaviour is controlled by your window manager, and you can't really do much about it.
(In my testing, it seems Xfwm4 and Fluxbox puts keep-above windows above dock/panel windows, despite what EWMH recommends, but perhaps your WM doesn't.)
There is, however, a very limited workaround: if you assume that the user will never have more than one dock/panel, you can set your window to be transient for that dock window. Usually (again, depending on window manager) this will keep your window above the dock window.
Update: In X11, you can set transient windows even if they are not in the same process. The simplest way I've found is using libwnck to get the XID of the panel window, then importing that to GDK using gdk_window_foreign_new. Of course, this won't work in non-X systems.
在参考页面说 gtk.Window.set_keep_above 只是对窗口管理器的一个请求,可能不会被满足,所以我想说这在所有情况下都不太可能发生。
无论如何,它还提供了一个有趣的信息:
也许您可以尝试为该信号设置回调,以确保尽快再次调用 gtk.Window.set_keep_above 。
In the reference page says that
gtk.Window.set_keep_above
is just a request to the window manager that might not be honored, so I'd say that is unlikely to make that happen under all circumstances.Anyway, it gives also an interesting piece of information:
Maybe you can try to set a callback for that signal to make sure
gtk.Window.set_keep_above
is called again as soon as possible.你可以这样做:
you can do it like this: