level 1
Tkinter treeview 背景色问题?
tree.insert("",0,values=(),tags=("123",))
tree.tag_configure("123",background="red")
利用tag改变treeview某一行的背景色,这在python3.6(win10)上没有问题,但在3.7及更高版本上却不会显示颜色。在一台win7电脑上3.7也能显示颜色。
这是为什么呢?如何能让3.7也正常变色呢?
2020年08月27日 15点08分
1
level 1
def fixed_map(option):
# Returns the style map for 'option' with any styles starting with
# ("!disabled", "!selected", ...) filtered out
# style.map() returns an empty list for missing options, so this should
# be future-safe
return [elm for elm in style.map("Treeview", query_opt=option)
if elm[:2] != ("!disabled", "!selected")]
style = ttk.Style()
style.map("Treeview",
foreground=fixed_map("foreground"),
background=fixed_map("background"))
代码中加上这几句,亲测有效,是python3.7一个已知未修复问题
2020年10月13日 05点10分
4
大佬
![[大拇指]](/static/emoticons/u5927u62c7u6307.png)
!确实有颜色了
2020年10月20日 03点10分
这个问题今天找了很久,谢谢分享!不胜感激
2020年10月22日 08点10分
这个问题今天找了很久,谢谢分享!不胜感激
2020年10月22日 08点10分