ErrorDialogs.py Disappeared?!?

andrea_gavana@tin.it wrote:

Hello NG,

    I have a couple of questions, not really complicated...

1) If I remember correctly, in wxPython 2.4.2.4 demo there was a demo regarding
some complex (and nice) error dialogs (ErrorDialogs.py? Not sure...). I'd
like to use them in order to handle some special exceptions/applications
bug/errors. May I ask you why have they been removed from the demo?

2) Does anyone know if there is some smart way to design throbbers in order
to use them in the Throbbers class in wxPython?

3) If my application encounter some bug/error that I was enable to trap,
is it possible to catch them in this way:

try:
    app = MyApplication(something)
    app.MainLoop()
except:
     Use_Some_Nice_Error_Dialogs()

?

Thank you a lot.

Andrea.

Decorators in python 2.4 and beyond can be a way of handling this.
I've stuffed in some code that I'm using myself. I've been readying
Python Cookbook Recipe for that (I think the address below works, I am
not sure).

     http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/391249

Essentially:

def watcherrors(function):
      '''function decorator to display Exception information.'''
      def substitute(*args, **kwargs):
          try:
              return function(*args, **kwargs)
          except Exception:
              error_type, error, traceback = sys.exc_info()
              msbox = wx.MessageDialog(None,
                          '%s\n\nClick OK to see traceback' % error,
                          'Error in Run',
                          wx.OK | wx.CANCEL | wx.ICON_ERROR)
              if wx.ID_OK == mb.ShowModal():
                  import os.path
                  msbox.Destroy()
                  from traceback import extract_tb
                  trace = ['%s line %s in %s:\n\t%s' % (
                             os.path.split(filename)[1], line, fun, text)
                           for filename, line, fun, text in
                               extract_tb(traceback)]
                  msbox = wx.MessageDialog(errorframe,
                          '\n'.join(['%s\n' % error] + trace),
                          'Run Error w/ Traceback',
                          wx.OK | wx.ICON_ERROR)
                  result = mb.ShowModal()
              msbox.Destroy()
              raise # Optional -- maybe squelch some errors here
          try:
              substitute.__doc__ = function.__doc__
          except AttributeError:
              pass
          return substitute

Then, define methods tied to a wx Event stimulus, as:

     @watcherrors
     def OnDoubleClick(....

--Scott David Daniels
Scott.Daniels@Acm.Org