Tkinter / Tcl callbacks, and return -code error
Jeff Epler
jepler at unpythonic.net
Tue Nov 5 11:43:10 EST 2002
On Tue, Nov 05, 2002 at 08:29:47AM -0800, Steve Davis wrote:
> I am working with a package written in C and Tcl/Tk, with python
> bindings. It allows me to set up some callback functions, which
> notify progress of long-running calculation, and can also cancel these
> calculations. I have the callbacks calling python functions, (using
> Tkinter "register()" function), but I can't figure out how to cancel
> the calculations.
>
> To cancel the calculations from Tcl, one is supposed to "return -code
> error". Unfortunately, there doesn't seem to be a python mechanism to
> do this. The closest I've come is by making a python object with no
> string representation, and returning that object. This approach goes
> too far, though - I get:
>
> Fatal Python error: PyThreadState_Get: no current thread
> Aborted
>
> It doesn't seem like my approach should kill the python interpreter,
> but I may be misunderstanding something.
>
> If it's relevant, I'm using the "snack" audio package
> (http://www.speech.kth.se/snack), and the "progress" callback
> functions available with various sound manipulations.
>
> So, is there a way to do the equivalent of the Tcl "return -code
> error" from within python? If not, is there some workaround?
> --
> http://mail.python.org/mailman/listinfo/python-list
It looks like raising an exception in a Python function called from TCL
should end up returning TCL_ERROR. It appears that there's an
"adderrorinfo" method as well.
Jeff
More information about the Python-list
mailing list