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-xy-stress.py < prev    next >
Encoding:
Python Source  |  2006-04-26  |  917 b   |  45 lines

  1. #!/usr/bin/env python
  2.  
  3. import pygtk
  4. pygtk.require('2.0')
  5. import gobject
  6. import gtk
  7. import gtk.gdk
  8. import pynotify
  9. import sys
  10. import random
  11.  
  12. exposed_signal_id = 0
  13. count = 0
  14.  
  15. def handle_closed(n):
  16.     print "Closing."
  17.  
  18. def emit_notification(x, y):
  19.     n = pynotify.Notification("X, Y Test",
  20.         "This notification should point to %d, %d." % (x, y))
  21.     n.set_hint("x", x)
  22.     n.set_hint("y", y)
  23.     n.connect('closed', handle_closed)
  24.     n.show()
  25.  
  26. def popup_random_bubble():
  27.     display = gtk.gdk.display_get_default()
  28.     screen = display.get_default_screen()
  29.     screen_x2 = screen.get_width() - 1
  30.     screen_y2 = screen.get_height() - 1
  31.  
  32.     x = random.randint(0, screen_x2)
  33.     y = random.randint(0, screen_y2)
  34.     emit_notification(x, y)
  35.     return True
  36.  
  37.  
  38. if __name__ == '__main__':
  39.     if not pynotify.init("XY Stress"):
  40.         sys.exit(1)
  41.  
  42.     gobject.timeout_add(1000, popup_random_bubble)
  43.  
  44.     gtk.main()
  45.