ArunRocks

Representing Anti-Monotonistic Tendencies
  • rss
  • Home
  • A little intro to Thrissur
  • Archives
    • Search
  • Resumé
  • About Me
    • Comment policy

Making Python Scripts Show Windows-friendly Errors/Stacktrace

Arun bhai | Wed, Jun 20, 2007

Most of us love to distribute our python programs to others once you have finished coding a neat little script. For Windows users we package it using Py2exe or cx_freeze. However, many of the end-users will not be happy with a black command window popping up, say, when an error is thrown.

Of course the alternative is to write a full blown GUI application using WXPython or PyFLTK. Even the latter, though quite lightweight, adds several megabytes to the distribution, when all you need is a simple message-box indicating an error or showing some informational text. Clearly, its an overkill for your throwaway python scripts.

This is the kind of problem I typically face and I have found a good solution. The answer is ctypes library which comes as a part of the standard distribution from Python 2.5 onwards. It simply calls the messagebox function from user32.dll (which is always present in a windows installation). With the main problem solved, what remained was to obtain the error text and stack trace.

Let’s see how the code looks like:

EDIT: This is how it looks like in PyMail, one of my scripts-that-grew-into-an-app ;)

Screenshot of a Python Stacktrace in a Messagebox

Bookmark this to del.icio.us | Digg | Furl | Netscape | Google Bookmarks | Technorati | reddit |

Comments
No Comments »
Categories
General, Python, Technical, py2exe
Comments rss Comments rss
Trackback Trackback

Your Email:

Categories

  • emacs
  • General
  • greasemonkey
  • indie
  • launchy
  • Pocketmod
  • productivity
  • py2exe
  • Reviews
    • Books
    • Movies
  • Short Stories
  • Technical
    • Gaming
      • Unni
    • Python
    • WordPress

Recent Posts

  • Ledger’s Joker Chills, Thrills and Entralls
  • Reading Hindu Online Made Better with Greasemonkey
  • Better Fonts Tip: Biggest Improvement in Ubuntu Appearance
  • Best Dialogs of Salim Kumar
  • Learning Pylons Through Tutorials

Recent Comments

  • Arun bhai on Best Dialogs of Salim Kumar
  • Thomas on Best Dialogs of Salim Kumar
  • Nidhish on Best Dialogs of Salim Kumar
  • abhilash on Learning Pylons Through Tutorials
  • Bookmarks about Ubuntu on Better Fonts Tip: Biggest Improvement in Ubuntu Appearance

Meta

  • Log in
  • Entries RSS
  • Comments RSS
  • WordPress.org

Bookmarks

del.icio.us/arun_ravindran I am arun_ravindran on del.icio.us
add arun_ravindran to your network Add me to your network
rss Comments rss valid xhtml 1.1 design by jide powered by Wordpress get firefox