几个月前我也遇到过同样的问题。
从tk文档:
You can assign a list of tags to each item using the "tags" item configuration option (again, when creating the item or later on).Tag configuration options can then be specified, which will then apply to all items having that tag.
基本上,您将一个标签应用于所有奇数行,将一个标签应用于每个偶数行,然后配置这些标签。
在树视图中创建项目时,请向其中添加标签:
tree.insert('', 'end', text = 'your text', tags = ('oddrow',))这段代码在中创建了一个元素
tree,并且
tags参数将标签“ oddrow”分配给了该元素。
使用’oddrow’和’evenrow’标签创建所有元素后,即可为标签着色:
tree.tag_configure('oddrow', background='orange')tree.tag_configure('evenrow', background='purple')


