home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / share / doc / python-notify / examples / test-image.py < prev    next >
Encoding:
Python Source  |  2006-04-25  |  1.0 KB  |  41 lines

  1. #!/usr/bin/env python
  2.  
  3. import pygtk
  4. pygtk.require('2.0')
  5. import pynotify
  6. import sys
  7. import gtk
  8. import os
  9.  
  10. if __name__ == '__main__':
  11.     if not pynotify.init("Images Test"):
  12.         sys.exit(1)
  13.  
  14.     # Stock icon
  15.     n = pynotify.Notification("Icon Test", "Testing stock icon",
  16.                               "stock_samples")
  17.  
  18.     if not n.show():
  19.         print "Failed to send notification"
  20.         sys.exit(1)
  21.  
  22.     # Image URI
  23.     uri = "file://" + os.path.abspath(os.path.curdir) + "/applet-critical.png"
  24.     print "Sending " + uri
  25.  
  26.     n = pynotify.Notification("Alert!", "Testing URI icons", uri)
  27.     if not n.show():
  28.         print "Failed to send notification"
  29.         sys.exit(1)
  30.  
  31.     # Raw image
  32.     n = pynotify.Notification("Raw image test",
  33.                               "Testing sending raw pixbufs")
  34.     helper = gtk.Button()
  35.     icon = helper.render_icon(gtk.STOCK_DIALOG_QUESTION, gtk.ICON_SIZE_DIALOG)
  36.     n.set_icon_from_pixbuf(icon)
  37.  
  38.     if not n.show():
  39.         print "Failed to send notification"
  40.         sys.exit(1)
  41.