Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Text小部件方法dump add参数_Python_Python 3.x_Tkinter_Text Widget - Fatal编程技术网

Python Text小部件方法dump add参数

Python Text小部件方法dump add参数,python,python-3.x,tkinter,text-widget,Python,Python 3.x,Tkinter,Text Widget,这是python/IDLE中名为: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 | pa

这是python/IDLE中名为: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.
我只能做到这一点(见下文)。不知道如何添加参数。我的意思是“标记”、“标签”、“文本”等

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

通过将以这些参数命名的关键字参数设置为
True
,可以添加参数。文档中有这样的权利(由我强调):

根据关键字筛选返回的内容类型 参数;如果给出了“全部”、“图像”、“标记”、“标记”、“文本”或“窗口”且为true,则返回相应的项

例如,要设置
标记
参数,您可以这样做:

text.dump("1.0", "end", tag=True)
类似地,要获取标记和文本信息,您可以执行以下操作:

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

... 这么简单。谢谢你,伙计。