tkinter.Text widget method dump add parameter

421 views Asked by At

this is content of help about Text widget method from python/IDLE named: dump

 |  dump(self, index1, index2=None, command=None, **kw)
 |      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.

I can only make this work (below). No idea how to add parameters to it. I mean 'mark', 'tag', 'text' etc.

myText.dump("sel.first","sel.last"):
1

There are 1 answers

1
Bryan Oakley On

You can add parameters by setting keyword arguments named after those parameters to True. It says this right in the documentation (with emphasis added by me):

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.

For example, to set the tag parameter you would do it like this:

text.dump("1.0", "end", tag=True)

Similarly, to get tag and text information you would do this:

text.dump("1.0", "end", tag=True, text=True)