I am trying to set colors to rows in a tkinter treeview object, using tags and tag_configure.
There has been an earlier discussion on coloring rows which is rather old and seems to work no longer for Python3:
ttk treeview: alternate row colors
I have added a brief example. For me, all rows stay white, independent of whether I execute tag_configure prior or after the insert command.
import tkinter as tk import tkinter.ttk as ttk root = tk.Tk() w = tk.Label(root, text="Hello, world!") w.pack() lb= ttk.Treeview(root, columns=['number', 'text'], show="headings", height =20) lb.tag_configure('gr', background='green') lb.column("number", anchor="center", width=10) lb.insert('',tk.END, values = ["1","testtext1"], tags=('gr',)) lb.insert('',tk.END, values = ["2","testtext2"]) lb.pack() root.mainloop() What has changed or what am I missing?
EDIT: Seems that this is a new known bug with a workaround, but I don't get this working: https://core.tcl-lang.org/tk/tktview?name=509cafafae
EDIT2: I am now using tk Version 8.6.10 (Build hfa6e2cd_0, Channel conda-forge) and python 3.7.3. Can anyone reproduce this error with this version of python and tk?
from tkinter import TkVersion; TkVersionin interactive mode, though never use ; in your real code)no longer for Python3-- this is an absolutely wrong sentence because Tk version is independent of Python version (though there is the default-installed Tk version, of course)