Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/307.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python GNOME中缺少图像/图标';s桌面通知_Python_Gtk_Pygtk_Gnome_Notify - Fatal编程技术网

Python GNOME中缺少图像/图标';s桌面通知

Python GNOME中缺少图像/图标';s桌面通知,python,gtk,pygtk,gnome,notify,Python,Gtk,Pygtk,Gnome,Notify,我试图通过Python脚本显示一个简单的GNOME桌面通知。据我所知,可以通过一个简单的文件URI(file://)显示带有通知的图像,但它只是拒绝在我的脚本中显示它: #!/usr/bin/python from gi.repository import Notify icon = "file://~/icon.png" Notify.init("Hello world") Hello = Notify.Notification.new("Hello world", "This is an e

我试图通过Python脚本显示一个简单的GNOME桌面通知。据我所知,可以通过一个简单的文件URI(file://)显示带有通知的图像,但它只是拒绝在我的脚本中显示它:

#!/usr/bin/python
from gi.repository import Notify
icon = "file://~/icon.png"
Notify.init("Hello world")
Hello = Notify.Notification.new("Hello world", "This is an example notification", icon)
Hello.show()
一个空白区域显示在图标应该出现的位置。我还尝试了.ico格式,但没有成功


我遗漏了什么吗?

将字符串
图标中的
~
替换为您的主目录的全名。Notify本身无法扩展该路径,因此请明确说明以消除该问题。

尝试将字符串图标中的
~
替换为您的主目录的全名?它可以工作,我很尴尬。非常感谢你!