Sending notifications using GObjects

It seems that there is currently no documentation for the GObjects module for python, so maybe someone can help me.

I am making an application that will occasionally notify the user that an event has occurred. I found about using from gi.repository import Notify and related classes from using a short snippet for Skype notifications and C documentation, but it doesn't seem to close when I call Notify.uninit. The program closes, but a small thing in the notification window remains placed and should be closed by right-clicking on it and selecting β€œDelete”. So, I am wondering if there is another way, as if there was something similar to how on Mac OS the application icon shakes / bounces when something happens, or on Windows the application icon glows in a different color?

I like the Gnome 3 notification system with a message stack, etc., but since I can’t make it disappear when my application exits, I don’t want to use it (if someone does not know how to do it right ... maybe I forgot to set a timeout, but it still doesn't make sense why I can't just remove the notification spot).

+6
source share
1 answer

Calling Notify.uninit does not mean that notifications disappear, it only tells libnotify that it will no longer be needed for your application. To prevent notifications from disappearing, you must close them explicitly, as in the following example:

 import time from gi.repository import Notify Notify.init('myapp') # optionally set an icon as the last argument n = Notify.Notification.new('summary text', 'body text', "dialog-information") n.show() # do whatever your application is doing time.sleep(10) n.close() Notify.uninit() 
+6
source

Source: https://habr.com/ru/post/919453/


All Articles