I am building a gui application using customtkinter (ctk). My main window is hence initialised with customtkinter. Treeview widgets don’t exist in ctk, hence I am using a treeview widget from tkinter ttk with its master assigned to a frame within the ctk main window. My system is MacOS usually set to dark mode natively. When I change my system from dark to light mode, I want it so that the treeview widget stays in dark mode. The code below achieves this for all the elements of the treeview widget apart from the heading, where the heading background still changes colour to a lighter colour but the text within the heading remains white. Any help is appreciated. Thanks!
style = ttk.Style()
style.theme_use('aqua')
# Configure the Treeview style
style.configure("Treeview",
background="#333333",
foreground="white",
fieldbackground="#333333",
bordercolor="#333333",
borderwidth=1)
style.map('Treeview',
background=[('selected', 'dark gray')],
foreground=[('selected', 'white')])
# Configure the Treeview Heading style
style.configure("Treeview.Heading",
background="#444444",
foreground="white",
bordercolor="#444444",
borderwidth=1,
relief='flat')
# Redefine the heading style options to ensure it remains dark
style.configure("Custom.Treeview.Heading",
background="#444444",
foreground="white",
bordercolor="#444444",
relief="flat")
style.map("Custom.Treeview.Heading",
background=[('active', '#5a5a5a'), ('!active', '#444444')],
foreground=[('active', 'white'), ('!active', 'white')],
relief=[('active', 'flat'), ('!active', 'flat')])
afairbridge is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.