1

I have applied this style to tkinter treeview but the data separator line got vanished

style_def = ttk.Style(frametree)
style_def.configure("Treeview",
    background="#FFDEAD",fieldbackground="#FFDEAD", foreground="Black",
    font=(None, 14), sheight=14, rowheight=30)
style_def.configure("Treeview.Heading",font=(None, 12))

I have tried without the style it works fine but when I merge it with the app which already has treeview, all the treeview gets the same style .So I changed the styling method and now I used the following.

style_defect = ttk.Style()
        style_defect.configure("fordefect.Treeview", background="#FFDEAD", foreground="black", fieldbackground="#FFDEAD",font=(None, 14), sheight=14, rowheight=30)
        style_defect.configure('fordefect.Treeview.Heading', background="white", font=('calibre', 14,"bold"))
        style_defect.map('fordefect.Treeview', background=[('selected', '#1E90FF')], foreground=[('selected', 'white')])
        self.tree = ttk.Treeview(frametree,height=26,style="fordefect.Treeview")

But now the border/item separator line has gone

  • 1
    If you don't want to alter all of the `"Treeview"` give it another name and use the `style=` option on the `ttk.Widget` and apply the costume name. Also, it is advisable to give a [mre] and may add an image of your `window` that shows what is wrong with your code. – Thingamabobs Jan 09 '23 at 12:00
  • This is the main tree ```class tree: def __init__(self): self.tree = ttk.Treeview(frametree,height=28) style_def = ttk.Style(frametree) style_def.configure("self.tree", background="#FFDEAD",fieldbackground="#FFDEAD", foreground="Black", font=(None, 14), sheight=14, rowheight=30) style_def.configure("Treeview.Heading",font=(None, 12))``` – Prashant Priyadarshi Jan 10 '23 at 06:41
  • This is how I called that tree ```if __name__ == "__main__": tree000 = tree() ``` – Prashant Priyadarshi Jan 10 '23 at 06:43
  • This is the affacted tree ```style_wear = ttk.Style(firsttreeframe) style_wear.configure("Treeview.Heading", font=(None, 13)) style_wear.configure("Treeview", font=(None, 12))``` placed like this ```tree02['show']='headings' tree02.grid(row=1,column=0,columnspan=4,sticky=EW)``` – Prashant Priyadarshi Jan 10 '23 at 08:13
  • @Thingamabobs please suggest I have applied this: ```style= ttk.Style() style.configure("add.Treeview", background="white", foreground="black", fieldbackground="white",font=('calibre', 12), sheight=10, rowheight=20) style.configure('add.Treeview.Heading', background="white", font=('calibre', 12),) style.map('add.Treeview', background=[('selected', '#1E90FF')], foreground=[('selected', 'white')]) t1= ttk.Treeview(firsttreeframe, show='headings', height=0,column=("c1", "c2",),style="add.Treeview")``` styling method but it doesn't have border color or separator color option how it can be done – Prashant Priyadarshi Jan 11 '23 at 05:36
  • Please add your code to your question not your comments – Thingamabobs Jan 11 '23 at 08:03

0 Answers0