1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
"""
test_pixbuf.py
Loads a pixbuf from a file, and sends it as data in a notification.
"""
import gtk
import os
import pynotify
import sys
SCRIPT_PATH = os.path.dirname(os.path.abspath(__file__))
ICON_PATH = os.path.join(SCRIPT_PATH, "..", "icons")
def main():
if len(sys.argv) < 2:
icon = os.path.join(ICON_PATH, "recent-notifications.svg")
else:
icon = os.path.join(ICON_PATH, sys.argv[1])
if not pynotify.init("test_pixbuf"):
print "Failed to initialize notifications."
sys.exit(1)
n = pynotify.Notification("TestPixbuf",
"This is a test, this is only a test.")
pixbuf = gtk.gdk.pixbuf_new_from_file(icon)
n.set_icon_from_pixbuf(pixbuf)
if not n.show():
print "Failed to send notification."
sys.exit(1)
if __name__ == "__main__":
main()
|