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-multi-actions.py < prev    next >
Encoding:
Python Source  |  2006-04-25  |  1.0 KB  |  45 lines

  1. #!/usr/bin/env python
  2.  
  3. import pygtk
  4. pygtk.require('2.0')
  5. import gtk
  6. import pynotify
  7. import sys
  8.  
  9. def help_cb(n, action):
  10.     assert action == "help"
  11.     print "You clicked Help"
  12.     n.close()
  13.     gtk.main_quit()
  14.  
  15. def ignore_cb(n, action):
  16.     assert action == "ignore"
  17.     print "You clicked Ignore"
  18.     n.close()
  19.     gtk.main_quit()
  20.  
  21. def empty_cb(n, action):
  22.     assert action == "empty"
  23.     print "You clicked Empty Trash"
  24.     n.close()
  25.     gtk.main_quit()
  26.  
  27. if __name__ == '__main__':
  28.     if not pynotify.init("Multi Action Test"):
  29.         sys.exit(1)
  30.  
  31.     n = pynotify.Notification("Low disk space",
  32.                               "You can free up some disk space by " +
  33.                               "emptying the trash can.")
  34.     n.set_urgency(pynotify.URGENCY_CRITICAL)
  35.     n.set_category("device")
  36.     n.add_action("help", "Help", help_cb)
  37.     n.add_action("ignore", "Ignore", ignore_cb)
  38.     n.add_action("empty", "Empty Trash", empty_cb)
  39.  
  40.     if not n.show():
  41.         print "Failed to send notification"
  42.         sys.exit(1)
  43.  
  44.     gtk.main()
  45.