打开 PyGTK 程序但不激活它
我有一个 PyGTK 程序,大部分时间都是隐藏的,但是按下按键它就会以弹出窗口的形式出现。因此我希望该程序在打开时不被激活。我尝试了几种选择,但没有成功:
self.window.show()
self.window.set_focus(无)
激活程序,但不设置焦点。
self.window.set_accept_focus(False)
self.window.show()
self.window.set_accept_focus(True)
使用最后一个命令,窗口将被激活。
self.window.show()
self.window.unset_flags(gtk.HAS_FOCUS)
不执行任何操作...
顺便说一句。我正在使用 Ubuntu 9.10 (metacity)
I have a PyGTK program which is hidden most of the time, but with a keypress it shall come up as a popup. Therefore I want the program not to be activated when its opened. I tried several options to to that, with no success:
self.window.show()
self.window.set_focus(None)
Activates the program, but sets no focus.
self.window.set_accept_focus(False)
self.window.show()
self.window.set_accept_focus(True)
With the last command, the window gets activated.
self.window.show()
self.window.unset_flags(gtk.HAS_FOCUS)
Does nothing...
Btw. I am using Ubuntu 9.10 (metacity)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
构建窗口,但在准备好激活之前不要对其调用
show()
。然后使用self.window.present( )
。编辑:
如果您不想激活该窗口,为什么不尝试弹出通知呢?为此,您需要 libnotify。有 Python 绑定。下面是一个示例: http://roscidus.com/desktop/node/336
组合使用工具栏小程序,这可以执行您想要的操作 - 即,当用户单击小程序或按下组合键时会引发通知。
Build the window but don't call
show()
on it until it is ready to be activated. Then useself.window.present()
.EDIT:
If you never want the window to be activated, why not try a notification popup? You need libnotify for this. There are Python bindings. Here is an example: http://roscidus.com/desktop/node/336
In combination with a toolbar applet, this could do what you want -- i.e. the notification is raised when the user either clicks on the applet or presses the key combination.