views:

946

answers:

7

I am looking for Growl-like, Windows balloon-tip-like notifications library in Python. Imagine writing code like:

>>> import desktopnotifier as dn
>>> dn.notify('Title', 'Long description goes here')

.. and that would notify with corresponding tooltips on Mac, Windows and Linux. Does such a library exist? If not, how would I go about writing one myself?

  • Does Mac come with a default notifier? Is Growl something that I should install separately?
  • On Windows, I assume this may require pywin32?
  • On Linux, assuming GNOME, is there a GNOME API (using gnome-python) that does this?
  • Can I make notifications 'sticky' (i.e., don't fade out ever) on all platforms?

Update: My preference is to not depend on gigantic GUI frameworks like PyQT4 and wxPython for a simple task such as this.

A: 

For Linux, you should look at dbus.

Ryan
A: 

For good cross-platform support, I would look at PyQt. It will add some heft to your library, but they've done a good job working out most of the kinks.

tghw
PyQT is too much for my simple requirement. Besides, deploying apps with PyQT is a *pain*: http://arstechnica.com/open-source/guides/2009/03/how-to-deploying-pyqt-applications-on-windows-and-mac-os-x.ars
Sridhar Ratnakumar
A: 

On win you can use snarl.

Using it with python: www.k23productions.com/e107_plugins/forum/forum_viewtopic.php?2972

Serra South
+3  A: 
  • How to go about writing it

    Check how keyring handles the cross-platform issues (it's a python library which plugs into various autodetected keychain backends for storage)

  • Growl isn't bundled with OSX you have to install it separately, OSX doesn't come with any built-in notification system.

  • For unices, you might want to hook into DBus as already mentioned (as a fallback, note that dbus might also be available in OSX), but both KDE and Gnome have Growl-like libraries. Respectively, KNotification for KDE and libnotify for Gnome.

  • For windows, check out Snarl, fall back no notification bubbles if not available (using something along the lines of ToasterBox)

Do not ever even think of making notifications sticky. It's stupid, it's insensitive and it's freaking annoying. Also, due to people like you it's been made not available in most notification systems.

Finally, even if there is no Python lib for any of these, you can probably use ctypes to access them.

masklinn
+8  A: 

Here's a desktop notifier I wrote a few years ago using wxPython - it behaves identically across Windows and Linux and should also run on OSX. It contains a threaded event loop that can be used to animate a notification window containing an icon and message that can be clicked on. It probably needs a couple of tweaks to customize it for your own purpose but the ground work is done.

Stephen McDonald
What license is this released under? Edit: Nevermind...it's a type of BSD license...thank you for releasing the code as such. It's a pain to find libraries or things I want to LEARN from that wouldn't risk any future releases of my code. But I have no problem giving credit where credit is due ;)
ThantiK
+2  A: 

try PyQt4, if you don't care about the size.

here is the class for this job: http://doc.trolltech.com/4.5/qsystemtrayicon.html

linjunhalida
A: 

Sounds like you need Growl for Windows

w0lf