Tkinter Treeview style

Why my table isn't changing style according to what I defined? I tried using style and map and it didn't change anything. It seems that the only thing that works is the Theme configuration. also the scroller isn't show in the Treeview.

from tkinter import *
from tkinter import ttk
class Dashboard:
def __init__(self, filterdDf): self.filterdDf = filterdDf root =Tk() root.title('Dashboard') root.geometry('1300x690') root.resizable(False, False) frame = Frame(root, width=1100, height=690) frame.configure(background="gray28") frame.pack(fill=BOTH, expand=True) rows = len(filterdDf) tree = ttk.Treeview(root, columns=(1, 2), height=rows, show="headings") tree.pack(side='left') tree.place(x=700, y=150) #Add some style: style = ttk.Style() style.theme_use("clam") style.configure("Treeview", background="silver", foreground="black", rowheight=55, fieldbackground="silver") #Change selected color: style.map("Treeview", background=[('selected', 'green')]) tree.heading("#0", text="Label", anchor=W) tree.heading("#1", text="Approach", anchor=CENTER) tree.heading("#2", text="Recommendation", anchor=CENTER) tree.column("#0", width=120, minwidth=25) tree.column("#1", width=300, minwidth=25, anchor=W) tree.column("#2", width=150, minwidth=25, anchor=CENTER) scroll = ttk.Scrollbar(frame, orient="vertical", command=tree.yview) scroll.pack(side='right', fill='y') tree.configure(yscrollcommand=scroll.set) for i in range(rows): tree.insert(parent='', index='end', values=(filterdDf[('Approaches', 'All')].iloc[i], filterdDf[('Recommendation Level', '')].iloc[i])) root.mainloop()

This is how my Treeview looks like: 2 columns filled with data. Thanks!

enter image description here

This is how it suppose to look with the style configuration (diffrent data but same configurations):

enter image description here

1 Related questions 17 ttk treeview: alternate row colors 0 Python multiple treeviews 3 Tkinter Treeview selection Related questions 17 ttk treeview: alternate row colors 0 Python multiple treeviews 3 Tkinter Treeview selection 2 tkinter ttk iterating through treeview 1 TTK Treeview doesn't display subtrees 8 Tkinter Treeview heading styling 11 How to fully change the background color on a tkinter.ttk Treeview 0 tkinter change style questions 7 tkinter ttk treeview colored rows 0 Treeview heading off by one column? Load 7 more related questions Show fewer related questions Reset to default

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

You Might Also Like