Categories
Mac Python

Python: Sending Growl Notifications

Growl is an extremely popular notification system for OS X. The application allows developers to display beautiful notification messages with ease. If you’re developing an application in Python and would like to integrate with Growl, this blog post is for you.

Introducing GNTP

Let me quote from the official docs here – http://www.growlforwindows.com/gfw/help/gntp.aspx#intro:

The Growl Network Transport Protocol, or GNTP, is a protocol to allow two-way communication between applications and centralized notification systems such as Growl for Mac OS X and to allow two-way communication between two machines running centralized notification systems for notification forwarding purposes.

In short, GNTP allows two way communication between your application and Growl. Even shorter – you can use GNTP to publish notifications using Growl.

GNTP Binding for Python

We have an excellent library for interacting with GNTP. The project is hosted on Github – https://github.com/kfdm/gntp/ and the docs are available here – http://pythonhosted.org/gntp/

So how to use this library? First, install the library using pip –

To see if the installation was ok, we can test by running the module directly –

Sending Notifications

Sending a quick notification from the Python interactive prompt:

Simple, right?

You can find advanced examples on the github readme and the docs (links above). Have fun with Python and Growl!