python : tkinter treeview colors are not updating python : tkinter treeview colors are not updating tkinter tkinter

python : tkinter treeview colors are not updating


As already mentioned this is a known issue with the tkinter library > 8.6.8. This version of tkinter is preinstalled with newer versions of Python (> 3.7).

A work around for this has been proposed here:https://core.tcl-lang.org/tk/tktview?name=509cafafae

Define the function that filters out arguments

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")]

Map the styling using the new function

style = ttk.Style()style.map("Treeview",           foreground=fixed_map("foreground"),          background=fixed_map("background"))

With this the tag_configure() should work as intended.


-what version of python are you using (python -V) in cmd

-the last version(3.7) of python seems like it has bugs to color tags

-if you are using python (3.7) just install python 3.6 (it may work with newer version also)