'Return the contents of the widget between index1 and index2.
The type of contents returned in filtered based on the keyword
parameters; if \'all\', \'image\', \'mark\', \'tag\', \'text\', or \'window\' are
given and true, then the corresponding items are returned. The result
is a list of triples of the form (key, value, index). If none of the
keywords are true then \'all\' is used by default.
If the \'command\' argument is given, it is called once for each element
of the list of triples, with the values of each triple serving as the
arguments to the function. In this case the list is not returned.'

def dump(self, index1, index2=None, command=None, **kw):

    args = []
    func_name = None
    result = None
    if (not command):
        result = []
        def append_triple(key, value, index, result=result):
            result.append((key, value, index))
        command = append_triple
    try:
        if (not isinstance(command, str)):
            func_name = command = self._register(command)
        args += ['-command', command]
        for key in kw:
            if kw[key]:
                args.append(('-' + key))
        args.append(index1)
        if index2:
            args.append(index2)
        self.tk.call(self._w, 'dump', *args)
        return result
    finally:
        if func_name:
            self.deletecommand(func_name)
