> does anyone know how to catch Python exceptions, before the program
> kicks out. I want to be able to show them in a dialog box, and let the
> user quit the program after that. The reason why is because I built an
> application using wxPyhon, and I made an exe with the installer package
> from Gordon McMillan, and I want to be able to catch all the errors that
> are still in the program, without letting the users having an extra window
> open which shows all messages (the standard dos window).
>
> Any ideas??
>
>
Create a class that has a write(self, string) method, create an instance of
it and assign it to sys.stderr. Now anyhtin written to that output stream
(including exception messages) will actiually be written to your object. You
can do whatever you want with it, display in a window, write to a file, send
it in an email to yourself...
Take a look near the end of wx.py for an example, wxPyOnDemandOutputWindow.
One of these is created if you construct your wxApp object without the zero,
IOW, "app = MyApp(1)"
The one problem with redirecting sys.stdout and sys.stderr is that it tends
to make debugging with pdb very difficult, so you'll want to make it
something that is optional or easily disabled forwhen you want to debug.
--
Robin Dunn
Software Craftsman
[hidden email]
http://AllDunn.com/robin/http://AllDunn.com/wxPython/ Check it out!
_______________________________________________
wxPython-users maillist -
[hidden email]
http://starship.python.net/mailman/listinfo/wxpython-users