Skip to main content
added 147 characters in body
Source Link
hezral
  • 339
  • 1
  • 8

This is my first time answering something on stack exchange. I found your post while trying to figure out the same problem. Finally found the answer on this site http://www.devdungeon.com/content/desktop-notifications-python-libnotify

I realize you are using subprocess but i also tried it and had the same problem. The code below may need some tweaking for subprocess to work.

I initially thought that i had to somehow set the image using Gtk.Image, several googles seems to lead to that, and it came down to setting the pixbuf and then setting the icon from there. This is my first time doing a script in Python and Gtk.

Anyway, the answer from the site is below. I followed exactly the same and managed to show my png file in the notification.

# This time import the GdkPixbuf module
from gi.repository import Notify, GdkPixbuf

Notify.init("Test App")
notification = Notify.Notification.new("Alert!")

# Use GdkPixbuf to create the proper image type
image = GdkPixbuf.Pixbuf.new_from_file("/home/NanoDano/test.png")

# Use the GdkPixbuf image
notification.set_icon_from_pixbuf(image)
notification.set_image_from_pixbuf(image)

notification.show()

This is my first time answering something on stack exchange. I found your post while trying to figure out the same problem. Finally found the answer on this site http://www.devdungeon.com/content/desktop-notifications-python-libnotify

I initially thought that i had to somehow set the image using Gtk.Image, several googles seems to lead to that, and it came down to setting the pixbuf and then setting the icon from there. This is my first time doing a script in Python and Gtk.

Anyway, the answer from the site is below. I followed exactly the same and managed to show my png file in the notification.

# This time import the GdkPixbuf module
from gi.repository import Notify, GdkPixbuf

Notify.init("Test App")
notification = Notify.Notification.new("Alert!")

# Use GdkPixbuf to create the proper image type
image = GdkPixbuf.Pixbuf.new_from_file("/home/NanoDano/test.png")

# Use the GdkPixbuf image
notification.set_icon_from_pixbuf(image)
notification.set_image_from_pixbuf(image)

notification.show()

This is my first time answering something on stack exchange. I found your post while trying to figure out the same problem. Finally found the answer on this site http://www.devdungeon.com/content/desktop-notifications-python-libnotify

I realize you are using subprocess but i also tried it and had the same problem. The code below may need some tweaking for subprocess to work.

I initially thought that i had to somehow set the image using Gtk.Image, several googles seems to lead to that, and it came down to setting the pixbuf and then setting the icon from there. This is my first time doing a script in Python and Gtk.

Anyway, the answer from the site is below. I followed exactly the same and managed to show my png file in the notification.

# This time import the GdkPixbuf module
from gi.repository import Notify, GdkPixbuf

Notify.init("Test App")
notification = Notify.Notification.new("Alert!")

# Use GdkPixbuf to create the proper image type
image = GdkPixbuf.Pixbuf.new_from_file("/home/NanoDano/test.png")

# Use the GdkPixbuf image
notification.set_icon_from_pixbuf(image)
notification.set_image_from_pixbuf(image)

notification.show()
Source Link
hezral
  • 339
  • 1
  • 8

This is my first time answering something on stack exchange. I found your post while trying to figure out the same problem. Finally found the answer on this site http://www.devdungeon.com/content/desktop-notifications-python-libnotify

I initially thought that i had to somehow set the image using Gtk.Image, several googles seems to lead to that, and it came down to setting the pixbuf and then setting the icon from there. This is my first time doing a script in Python and Gtk.

Anyway, the answer from the site is below. I followed exactly the same and managed to show my png file in the notification.

# This time import the GdkPixbuf module
from gi.repository import Notify, GdkPixbuf

Notify.init("Test App")
notification = Notify.Notification.new("Alert!")

# Use GdkPixbuf to create the proper image type
image = GdkPixbuf.Pixbuf.new_from_file("/home/NanoDano/test.png")

# Use the GdkPixbuf image
notification.set_icon_from_pixbuf(image)
notification.set_image_from_pixbuf(image)

notification.show()