modifying tag for the item in tkinter treeview

一个人想着一个人 提交于 2020-06-26 06:15:40

问题


is there any way I could modify the the tkinter treeview item tag? I know how to create item with tag with insert command, but when I: tree.set(tree.selection()[0],0,'some text in red', tags='red') I get TypeError: set() got an unexpected keyword argument 'tags'

The ultimate goal is to change row or column colors... Thanks!


回答1:


The documentation on Treeview (here for instance) says that there is a method called item that can be used to set or retrieve the options of a tree item.

  • tree.item(iid, "tags") returns the list of tags of the item identified by iid

  • tree.item(iid, tags="red") changes the tags of iid to ("red",). You can also pass a tuple of tags like tags=("bold", "red").



来源:https://stackoverflow.com/questions/42298711/modifying-tag-for-the-item-in-tkinter-treeview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!