Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Clock screenlet protoype using the NotifyOSD graphic interface
#!/usr/bin/env python
try:
import gtk, gobject, pygtk, os, os.path, pynotify, time
pygtk.require('2.0')
except:
print "Error: need python-notify, python-gtk2, python-gobject and gtk"
def my_timer(n):
n.update("NotifyOSD Clock", time.asctime())
n.show()
return True
if __name__ == '__main__':
if not pynotify.init("NotifyOSD Clock"):
sys.exit(1)
n = pynotify.Notification("NotifyOSD Clock", time.asctime())
#n = pynotify.Notification("Moo title", "test", "file:///path/to/icon.png")
n.set_urgency(pynotify.URGENCY_LOW)
n.set_timeout(1000)
#Call an icon
helper = gtk.Button()
#print gtk.stock_list_ids()
icon = helper.render_icon(gtk.STOCK_INFO, gtk.ICON_SIZE_DIALOG)
n.set_icon_from_pixbuf(icon)
gobject.timeout_add(1000, my_timer, n) #update each second
loop = gobject.MainLoop()
loop.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment