Python AppIndicator绑定->如何检查菜单是否打开? [英] Python AppIndicator bindings -> howto check if the menu is open?

查看:115
本文介绍了Python AppIndicator绑定->如何检查菜单是否打开?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是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()

不幸的是,有关此文件的信息很不完整.我正在寻找一种检查用户是否打开了AppIndicator菜单的方法(例如,单击了指示器图标).那么打开菜单时会发出信号吗?

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?

推荐答案

不幸的是,答案似乎并非如此.

It looks like the answer is no unfortunately.

print gobject.signal_list_names(ind)
('new-icon', 'new-attention-icon', 'new-status', 'new-label', 'x-ayatana-new-label', 'connection-changed', 'new-icon-theme-path')

我尝试了所有这些,单击指示器后似乎没有一个激活.为了值得一做,统一开发人员似乎希望保持所有指标的行为统一,因此有意对其进行限制是很有可能的.

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.

这篇关于Python AppIndicator绑定->如何检查菜单是否打开?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆