Python 树视图更新标签
Python treeview update tag
我已将项目插入到带有标签选项的 Python treeview
中。
tree.insert("", 'end', 'item1', text='item1', tags=('new',))
以后可以将标签 "new"
更改为其他内容吗?
您可以修改项目的任何选项。因此,如果您想将 'item1'
标签更改为例如 'old'
:
tree.item('item1', tags=('old'))
从 Python docs 关于 ttk.Treeview
:
item(item, option=None, **kw) Query or modify the options for the
specified item.
If no options are given, a dict with options/values for the item is
returned. If option is specified then the value for that option is
returned. Otherwise, sets the options to the corresponding values as
given by kw.
我已将项目插入到带有标签选项的 Python treeview
中。
tree.insert("", 'end', 'item1', text='item1', tags=('new',))
以后可以将标签 "new"
更改为其他内容吗?
您可以修改项目的任何选项。因此,如果您想将 'item1'
标签更改为例如 'old'
:
tree.item('item1', tags=('old'))
从 Python docs 关于 ttk.Treeview
:
item(item, option=None, **kw) Query or modify the options for the specified item.
If no options are given, a dict with options/values for the item is returned. If option is specified then the value for that option is returned. Otherwise, sets the options to the corresponding values as given by kw.