How to configure ttk.Treeview item color in Python 3.7.3? How to configure ttk.Treeview item color in Python 3.7.3? tkinter tkinter

How to configure ttk.Treeview item color in Python 3.7.3?


Maybe I'm a bit late here but...

You're surely facing a known bug affecting Windows Python builds shipping tk v8.6.9.

To solve, add this code on top of yours (before instantiating the Treeview):

import tkinter as tkimport tkinter.ttk as ttkroot = tk.Tk()s = ttk.Style()#from os import name as OS_Nameif root.getvar('tk_patchLevel')=='8.6.9': #and OS_Name=='nt':    def fixed_map(option):        # Fix for setting text colour for Tkinter 8.6.9        # From: https://core.tcl.tk/tk/info/509cafafae        #        # 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 s.map('Treeview', query_opt=option) if elm[:2] != ('!disabled', '!selected')]    s.map('Treeview', foreground=fixed_map('foreground'), background=fixed_map('background'))


It's working properly no issue we run it on python 3.7x. Here we attached the screenshot.

enter image description here