This is one of my favorites ever:
To do dataflow from Tk, I settled on:
trace add variable .w42 write "mytraceproc"
And mytraceproc cloned from sendata et al.
After a fascinating learning period I got it to work. Most of the time.
When it fails (get this) it is because the sympol is in a different package (My "LTk2" package.) That is the listener package while I am running. Normally callback gets symbols in LTk, and that is how they are stored in the callback hash table.
What triggers this just some of the time? Amazing:
typing text is ok deleting text with backspace is ok selecting text and then deleting it with backspace is OK selecting text and then typing text (causing the selection first to be deleted).... ...is NOT ok.
How does LTk end up with a symbol in the same package based on what the user is doing to the field?
My guess is that Tk sends two messages, one delete, one insert, and that some different codebranch is (a) reached because of the unusual circumstances and (b) does something funny with *package*.
ken