Koodilistaus:Jamoget-finished-notification.py

Mummilan wikistä
Versio hetkellä 9. marraskuuta 2011 kello 20.52 – tehnyt Jani Uusitalo (keskustelu | muokkaukset) (Tekstin korvaus – ”<metadesc content="([^"]*)" \/>” muotoon ”<metadesc>$1</metadesc>”)

<metadesc>Python-komentojono, joka näyttää ponnahdusilmoituksen Jamendo-latauksien valmistumisesta.</metadesc> Lataa tiedostona: [{{#file: jamoget-finished-notification.py}} jamoget-finished-notification.py]

Python-komentojono, joka näyttää ponnahdusilmoituksen Jamendo-latauksien valmistumisesta.

Katso myös

{{#fileanchor: jamoget-finished-notification.py}}

#!/usr/bin/env python
try:
    import gtk, pygtk, os, os.path, pynotify
    pygtk.require('2.0')
except:
    print "Error: need python-notify, python-gtk2 and gtk"

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

    n = pynotify.Notification("Jamoget", "Lataukset valmistuivat.")
    #n = pynotify.Notification("Foo title", "Foo text", "file:///path/to/icon.png")
    n.set_urgency(pynotify.URGENCY_CRITICAL)
    n.set_timeout(10000) # 10 seconds
    n.set_category("device")

    #Call an icon
    helper = gtk.Button()

    # http://www.pygtk.org/docs/pygtk/gtk-stock-items.html
    icon = helper.render_icon(gtk.STOCK_DIALOG_INFO, gtk.ICON_SIZE_DIALOG)
    n.set_icon_from_pixbuf(icon)

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