且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何更改 Treeview 的背景颜色

更新时间:2023-01-27 10:55:26

缺少的选项是 fieldbackground 我只是偶然发现的 示例中.所以如果你把它添加到样式声明中

The missing option is fieldbackground which I only found by accident in an example. So if you add it to the style declaration

ttk.Style().configure("Treeview", background="#383838", 
 foreground="white", fieldbackground="red")

它可以如你所愿.我使用 red 使更改非常明显;显然你会想要改变它以获得更大的色彩和谐.

it works as you'd like. I used red to make the change very visible; obviously you'll want to change that for greater color harmony.