David Woods wrote:
I'm seeing something odd, and wonder if anyone has seen it before and knows
a work-around.I collect data from the user and save it in a database. If there's a
problem saving the data (duplicate record values, for example), then I raise
an exception, which I trap so I can ask the user to change the offending
value. It seems to work fine, with one exception, (no pun intended.)If my user initiates the process where s/he is asked for data during a
drag-and-drop operation, my exception just disappears, and the program acts
like the drag was cancelled. The result is that I can't catch an
easily-correctable problem and let my user correct it, at least not using
exceptions. There are a couple of places in my program where drag-and-drop
is the easiest UI way to signal that certain objects need to be created.
When doing the DnD there is an extra set of layers in the C++/Python sandwich, and so when control returns from Python --> C++ any unhandled exceptions are printed and the error is cleared. The way things are currently it is too hard to pass the exception across the C++ layer up to the next Python layer without causing worse problems, (although now that wxWindows has been made more exception safe in 2.5 and with changes in the new SWIG there is hope that it can change in the future.)
It will take me quite a bit of effort to rework my code to return error
codes rather than using exceptions, so I'm hoping someone has some ideas
that will help me avoid having to do that. Any ideas, anyone?
Try to catch the exception in the same Python layer that raises it, and then use wxCallAfter to cause some other function to be executed after the DnD is over and then prompt the user that the value needs changed.
ยทยทยท
--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!