从
TkDocs tutorial到树木,似乎你可以:
>创建具有所需颜色的标记(对于选定的行)
然后,从树视图中捕获虚拟事件:
>在获得焦点时将标记分配给行
>当焦点失去焦点时,从行中取消分配标签
这是我使用的文档中的特定段落:
The treeview will generate virtual events "", ""
and "" which allow you to monitor changes to the widget made
by the user. You can use the "selection" method to determine the current
selection (the selection can also be changed from your program).
以及教程中的一些代码:
tree.tag_configure('ttk', background='yellow')
tree.tag_bind('ttk', '<1>', itemClicked); # the item clicked can be found via tree.focus()
注意:我不确定这是否有效.我将不得不挖掘代码来看看我做了什么.