# Create the text widget
pack [text .t]
# The flag
global flag
set flag 0
# Put a trace on the flag to execute your proc
trace variable flag w changed
# rename the widget procedure
rename .t orig_t
# the new widget procedure
proc .t {args} {
global flag
set returnVal [eval [concat orig_t $args]]
set command [lindex $args 0]
if {[string equal $command "insert"] || [string equal $command "delete"]} {
set flag 1
}
return $returnVal
}
# Whatever you need to do when something changes
proc changed {args} {
puts "something changed"
}Wcb, the widget callback package which can be found at http://www.nemethi.de/ is a more general way to do this.Arts and crafts of Tcl-Tk programming
Category GUI
