Tkinter / Tcl callbacks, and return -code error

Steve Davis sdati at hotmail.com
Tue Nov 5 11:29:47 EST 2002


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?



More information about the Python-list mailing list