Is it possible to call Tcl procedures that have function pointers (or callback functions) from Python?
I am using Tkinter to call Tcl procedures from Python.
Python Snippet :
proc callbackFunc():
print "I am in callbackFunc"
cb = callbackFunc
Tkinter.Tk.call('tclproc::RetrieveInfo', cb)
Tcl Snippet :
proc tclproc::RetrieveInfo() { callback } {
eval $callback
}
Note I cannot modify Tcl code as its an external library to my application.
//Hemanth
Yes, and your pseudocode is pretty close. You have to register your python code with the Tcl interpreter. This will create a tcl command that will call your python code. You then reference this new tcl command whenever you pass it to a Tcl procedure that expects a procedure name. It goes something like this:
A tiny bit of documentation is here:
http://epydoc.sourceforge.net/stdlib/Tkinter.Misc-class.html#register