Speno's Pythonic Avocado 14.1.2004


EasyDialogs on MacOS X

My photo gallery application needed an update for MacOS X. MacPython's buildapplet program turned out a Python 2.2 application which still works fine. However, I wanted to turn it into a "real" MacOS X application and that meant turning my script into an application bundle.

One of the consequences of doing this was losing a console window which handled standard input and output. Buildapplet had given me this feature for free. Using the console, my script could just use print statements for feedback. I wanted the new version to have better looking feedback, but I didn't want to spend much time on making it work. Luckily I didn't have to.

I knew that Python had a large mac toolbox as part of the standard python install in it's plat-darwin directory. Just take a look at all those (Mac) designations on the Global Module Index and you'll see what I mean. The one module in particular which caught my eye was EasyDialogs.

Using EasyDialogs.py, I was quickly able to add a nice progress bar to my application as well as a dialog box to display some useful feedback. Here's an example of how to use them:

import EasyDialogs import time images = [str(x) + '.jpg' for x in range(50)] image_count = len(images) progress = EasyDialogs.ProgressBar(title='Creating Gallery', maxval=image_count) for image in images: progress.label('Processing %s' % image) progress.inc() time.sleep(0.1) EasyDialogs.Message("Finished processing %d images" % image_count)

If you are running this from the command-line on MacOS X, make sure you use pythonw instead of python since you need to use the windowmanager.

Take care.

posted at 21:29:20    #    comment []    trackback []
January 2004
    1 2 3 4
5 6 7 8 91011

One python programmer's search for understanding and avocados. This isn't personal, only pythonic.

XML-Image Letterimage

© 2004-2005, John P. Speno