This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Color setting doesn't work in tkinter
Type: behavior Stage: resolved
Components: Tkinter Versions: Python 3.8, Python 3.7
process
Status: closed Resolution: duplicate
Dependencies: Superseder: Treeview: wrong color change
View: 36468
Assigned To: Nosy List: Acid Ascorbic, ned.deily
Priority: normal Keywords:

Created on 2019-11-26 14:47 by Acid Ascorbic, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (2)
msg357501 - (view) Author: Acid Ascorbic (Acid Ascorbic) Date: 2019-11-26 14:47
It is impossible to set colors properly in Treeview.
Python behavior is different between versions 3.6.2 and 3.7.3/3.8.0.
Origin: https://stackoverflow.com/questions/57634982/can-i-change-the-foreground-color-of-a-single-column-in-python-treeview/59047842
Example 1:

from tkinter import ttk
import tkinter as tk

root = tk.Tk()
tree = ttk.Treeview(root)
c = tree.insert('', 'end', text='This is critical message', tags='critical')
tree.insert(c, 'end', text='This is child of critical message', tags='critical')
for i in range(5):
    tree.insert('', 'end', text='This is non-critical message')
tree.tag_configure('critical', background='red', foreground="black")
tree.pack()
root.mainloop()

Example 2:

import tkinter as tk
from tkinter import ttk

root = tk.Tk()
style = ttk.Style(root)
style.theme_use("clam")
style.configure("Treeview", background="black",
                fieldbackground="black", foreground="white")
tree = ttk.Treeview(root)
tree.insert("", 0, "item", text="item")
tree.pack()
root.mainloop()
msg357608 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2019-11-28 06:38
I believe this is a duplicate of Issue36468 which identifies the issue which is apparently fixed in Tk 8.6.9+; it also provides a workaround for Tk 8.6.8.
History
Date User Action Args
2022-04-11 14:59:23adminsetgithub: 83098
2019-11-28 06:38:05ned.deilysetstatus: open -> closed

superseder: Treeview: wrong color change

nosy: + ned.deily
messages: + msg357608
resolution: duplicate
stage: resolved
2019-11-26 14:47:48Acid Ascorbiccreate