'Initialize attributes and setup redirection.
_operations: dict mapping operation name to new function.
widget: the widget whose tcl command is to be intercepted.
tk: widget.tk, a convenience attribute, probably not needed.
orig: new name of the original tcl command.
Since renaming to orig fails with TclError when orig already
exists, only one WidgetDirector can exist for a given widget.'

def __init__(self, widget):

    self._operations = {}
    self.widget = widget
    self.tk = tk = widget.tk
    w = widget._w
    self.orig = (w + '_orig')
    tk.call('rename', w, self.orig)
    tk.createcommand(w, self.dispatch)
