'Callback from Tcl which runs when the widget is referenced.
If an operation has been registered in self._operations, apply the
associated function to the args passed into Tcl. Otherwise, pass the
operation through to Tk via the original Tcl function.
Note that if a registered function is called, the operation is not
passed through to Tk.  Apply the function returned by self.register()
to *args to accomplish that.  For an example, see colorizer.py.'

def dispatch(self, operation, *args):

    m = self._operations.get(operation)
    try:
        if m:
            return m(*args)
        else:
            return self.tk.call(((self.orig, operation) + args))
    except TclError:
        return ''
