如何在StatusIcon上显示文本而不是设置图标? [英] How can I display text on a StatusIcon instead of setting an icon?

查看:111
本文介绍了如何在StatusIcon上显示文本而不是设置图标?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Gtk和Python中的初级开发人员。我试图创建一个gtk.StatusIcon来显示一个文本字符串来代替一个图标。我怎样才能用PixBuf或者其他方式来实现这一点?



谢谢。

解决方案

使用屏幕外的GtkLabel,然后调用 gdk_pixbuf_get_from_drawable(gtk_widget_get_snapshot(()),这是可能的 - 想到两个想法: )(一个GdkPixmap是一个GdkDrawable)。这将执行XGetImage以从X服务器获取像素。



b。)或者您可以使用Cairo将文本绘制到pixbuf--这是GNOME中用于键盘状态图标的技术: http://blogs.gnome.org/sudaltsov/category/general/


I'm a beginner developer in Gtk and also in Python. I'm trying to create a gtk.StatusIcon displaying a text string in place of a icon. How can I accomplish this with PixBuf, or any other way?

Thanks.

解决方案

This is possible - two ideas come to mind:

a.) Use an offscreen GtkLabel and then call gdk_pixbuf_get_from_drawable (gtk_widget_get_snapshot (label)) (a GdkPixmap is a GdkDrawable.) This will do an XGetImage to get pixels from the X server.

b.) Or you could use Cairo to draw text to the pixbuf - this is the technique that was used for the keyboard status icon in GNOME: http://blogs.gnome.org/sudaltsov/category/general/

这篇关于如何在StatusIcon上显示文本而不是设置图标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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