Python AppIndicator 绑定 ->如何检查菜单是否打开?
这是 AppIndicator 的一个最小示例:
#!/usr/bin/python
import gobject
import gtk
import appindicator
if __name__ == "__main__":
ind = appindicator.Indicator("example-simple-client", "gtk-execute", appindicator.CATEGORY_APPLICATION_STATUS)
ind.set_status (appindicator.STATUS_ACTIVE)
menu = gtk.Menu()
menu_items = gtk.MenuItem('Quit')
menu.append(menu_items)
menu_items.connect("activate", gtk.main_quit)
menu_items.show()
ind.set_menu(menu)
gtk.main()
不幸的是,有关此的文档非常不完整。我正在寻找一种方法来检查用户是否打开了 AppIndicator 菜单(例如单击了指示器图标)。那么打开菜单时是否会发出信号?
Here is a minimal example of an AppIndicator:
#!/usr/bin/python
import gobject
import gtk
import appindicator
if __name__ == "__main__":
ind = appindicator.Indicator("example-simple-client", "gtk-execute", appindicator.CATEGORY_APPLICATION_STATUS)
ind.set_status (appindicator.STATUS_ACTIVE)
menu = gtk.Menu()
menu_items = gtk.MenuItem('Quit')
menu.append(menu_items)
menu_items.connect("activate", gtk.main_quit)
menu_items.show()
ind.set_menu(menu)
gtk.main()
Unfortunately the documentation on this is very incomplete. What I'm looking for is a way to check if the AppIndicator menu was opend by the user (e.g. the indicator icon was clicked). So is there a signal, that is emitted when the menu is opened?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不幸的是,答案似乎是否定的。
我尝试了所有这些,但单击指示器时它们似乎都没有激活。值得一提的是,统一开发人员似乎希望保持所有指标以统一的方式运行,因此很可能是故意限制的。
It looks like the answer is no unfortunately.
I tried all of them and none of them appear to activate when the indicator is clicked. For what it's worth the unity devs seem to want to keep all indicators behaving in a uniform way, so it's quite possible that it's deliberately limited.
Launchpad 上有一个关于它的错误 https://bugs.launchpad.net/screenlets/+ bug/522152
请注意,“激活”信号可用于 AppIndicator 子菜单。
There is a bug filed about it on Launchpad https://bugs.launchpad.net/screenlets/+bug/522152
Notice that "activate" signal is available for AppIndicator submenus.