File: test-image.py

package info (click to toggle)
notify-python 0.1.1-3
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 1,516 kB
  • sloc: sh: 8,496; ansic: 622; python: 255; makefile: 110
file content (40 lines) | stat: -rwxr-xr-x 1,035 bytes parent folder | download | duplicates (4)
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
38
39
40
#!/usr/bin/env python

import pygtk
pygtk.require('2.0')
import pynotify
import sys
import gtk
import os

if __name__ == '__main__':
    if not pynotify.init("Images Test"):
        sys.exit(1)

    # Stock icon
    n = pynotify.Notification("Icon Test", "Testing stock icon",
                              "stock_samples")

    if not n.show():
        print "Failed to send notification"
        sys.exit(1)

    # Image URI
    uri = "file://" + os.path.abspath(os.path.curdir) + "/applet-critical.png"
    print "Sending " + uri

    n = pynotify.Notification("Alert!", "Testing URI icons", uri)
    if not n.show():
        print "Failed to send notification"
        sys.exit(1)

    # Raw image
    n = pynotify.Notification("Raw image test",
                              "Testing sending raw pixbufs")
    helper = gtk.Button()
    icon = helper.render_icon(gtk.STOCK_DIALOG_QUESTION, gtk.ICON_SIZE_DIALOG)
    n.set_icon_from_pixbuf(icon)

    if not n.show():
        print "Failed to send notification"
        sys.exit(1)