简体   繁体   中英

tkinter.Text widget method dump add parameter

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"):

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM