PyZenity is an easy to use interface to Zenity for Python.  Zenity is normally called from scripts by invoking it with a multitude of command line parameters that it uses to construct its interfaces.  This module hides the details of invoking the command and presents simple API functions like:

cancel = Question('Should I cancel the operation?')

Why PyZenity?

Well I originally wrote PyZenity a few years ago when I decided I wanted to learn how to use the new (in Python 2.4) subprocess module. Now I needed a command that I could use to experiment with and I thought, “hey, what better program then Zenity.” It takes lots of parameters, has well defined return values, and I could experiment right from the interactive shell because it spawned a GUI. So I wrote functions to call Zenity’s widgets and played around for a bit exercising some of the features of subprocess. When I was done I thought, “Maybe someone would be interested in this”, so I documented it and threw it up on my website. Lo and behold, a few people were and I occasionally get bug fixes for it.

Others have noted that the proper thing to do is use PyGTK to create interactive GUIs and I totally agree. But if your interest is in creating quick scripts to get the job done, PyZenity is much easier to use.

Note for Windows Users: PyZenity appears to work out of the box with the Windows version of Zenity here.

The current version is 0.1.7.

The documentation is available here.

Release Notes

  1. Version 0.1.7 – Shane Mclafferty pointed out that there is no “ok-label” and “cancel-label” parameters. Added an optional “ok_label” and “cancel_label” parameters to remedy this.
  2. Version 0.1.6 – Ben suggested that the GetDate function return a 4 digit year to make life a whole lot easier.
  3. Version 0.1.5 – Adds kwargs to functions to specify optional Zenity parameters like height, width, etc.
  4. Version 0.1.4 – Dietmar Thaler fixed a ValueError bug in PyZenity.List when using the boolstyle parameter.
  5. Version 0.1.3 – The PKG-INFO file says PyZenity is under the BSD License but it’s actually under the MIT License.  Thanks to Siegfried-Angel for pointing that out!
  6. Version 0.1.2 – Felix Hummel found and fixed an ImportError when using the GetDirectory function caused by a failure to import os.path.
  7. Version 0.1.1 – Fixed a bug with the GetDate function not taking into account locale while parsing the return from zenity.  Thanks to Matt Williams for finding the bug.
  8. Version 0.1 – Initial version.