'Return a newly created Tcl function. If this
function is called, the Python function FUNC will
be executed. An optional function SUBST can
be given which will be executed before FUNC.'

def _register(self, func, subst=None, needcleanup=1):

    f = CallWrapper(func, subst, self).__call__
    name = repr(id(f))
    try:
        func = func.im_func
    except AttributeError:
        pass
    try:
        name = (name + func.__name__)
    except AttributeError:
        pass
    self.tk.createcommand(name, f)
    if needcleanup:
        if (self._tclCommands is None):
            self._tclCommands = []
        self._tclCommands.append(name)
    return name
