我最近注意到,在ubuntu unity中,应用程序指示器(代替系统托盘)不显示我添加到gtk股票中的自定义图标,而仅显示基本股票图标。代替正确的图标,我看到了“ gtk-missing-image”。在我的应用程序工具栏和菜单上,那些图标正确显示,问题仅在于顶部的应用程序指示器。通过这种方式集成了股票图标后,我使用了gtk ui管理器:
factory = gtk.IconFactory()
pixbuf = gtk.gdk.pixbuf_new_from_file(filepath)
iconset = gtk.IconSet(pixbuf)
factory.add(stock_name, iconset)
factory.add_default()
然后是指示符代码:
.....
try:
import appindicator
HAS_APPINDICATOR = True
except: HAS_APPINDICATOR = False
....
if HAS_APPINDICATOR:
self.ind = appindicator.Indicator("x-tile", "indicator-messages", appindicator.CATEGORY_APPLICATION_STATUS)
self.ind.set_status(appindicator.STATUS_ACTIVE)
self.ind.set_attention_icon("indicator-messages-new")
self.ind.set_icon("x-tile")
self.ind.set_menu(self.ui.get_widget("/SysTrayMenu"))
else:
self.status_icon = gtk.StatusIcon()
self.status_icon.set_from_stock("Tile Quad")
self.status_icon.connect('button-press-event', self.on_mouse_button_clicked_systray)
self.status_icon.set_tooltip(_("Tile the Windows Upon your X Desktop"))
完整代码:
hg clone https://giuspen-x-tile.googlecode.com/hg/ hg_x-tile
cd hg_x-tile
hg up x-tile2
使用系统托盘时,图标可见,但没有应用程序指示器时,可见。如果有人解决了此问题,请提供帮助。
无法使用在指示器中即时创建的库存图标。
使用statusicons时,您的应用程序将负责构建和显示菜单。但是,在使用指示符时,实际上是您的应用程序发出了一个请求,而真正构建和显示菜单的人是在后台运行的服务。
该服务是一个独立的程序,与您的程序完全分开。因此,它不了解您即时创建的诸如环境变量和股票图标名称之类的东西。
最好的解决方法是使用指示器的set_icon_theme_path来告诉它图标在哪里。在这种情况下,您甚至不需要更改库存。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句