简体   繁体   English

Tkinter Treeview - 条件格式 - 单个单元格颜色

[英]Tkinter Treeview - Conditional Formatting - Individual cell colours

I'm currently using Tkinter's Treeview to display a table of data in my GUI, and would like to apply conditional formatting in the Treeview widget so that the background colour of a cell depends on that cell's value (eg 0 would be red, and 1-6 are green).我目前正在使用 Tkinter 的 Treeview 在我的 GUI 中显示数据表,并希望在 Treeview 小部件中应用条件格式,以便单元格的背景颜色取决于该单元格的值(例如 0 将是红色,而 1 -6 为绿色)。 Very much like Excel's conditional formatting.非常像 Excel 的条件格式。

My program reads a CSV file and converts it to a Pandas DataFrame, and I use the Treeview widget to display that data.我的程序读取 CSV 文件并将其转换为 Pandas DataFrame,我使用 ZC43FAF42E29CAD508E044 显示数据的小部件I also have buttons in my GUI that lets the user filter the data depending on which button is clicked.我的 GUI 中还有一些按钮,可让用户根据单击的按钮过滤数据。

I haven't been able to find or think of an easy solution.我无法找到或想出一个简单的解决方案。 Would anyone know of a possible work-around or an alternative please?请问有人知道可能的解决方法或替代方法吗?

Desired example output所需示例 output

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM