I am trying to style my treeview
#Treeview Style
treeStyle = ttk.Style()
treeStyle.configure("mystyle.Treeview", highlightthickness=0, bd=0, font=('Arial', 11)) # Modify the font of the body
treeStyle.configure("mystyle.Treeview.Heading", font=('Arial', 13,'bold')) # Modify the font of the headings
treeStyle.layout("mystyle.Treeview", [('mystyle.Treeview.treearea', {'sticky': 'nswe'})]) # Remove the borders
#treeview Frame Widgets Define
EmployView=ttk.Treeview(treeviewFrame,style=treeStyle)
However when I run the above code I get this error:
_tkinter.TclError: Layout <tkinter.ttk.Style object at 0x02FEAAF0> not found
I have clearly defined the style, so I'm confused as to why it is not being found.
The issue here is that you are not passing the right argument to the style
option of the treeview. This option is not expecting a Style
object but a string, in your case "mystyle.Treeview". The widgets' styles are just strings of the form "<stylename>.<Layout>"
(if you don't put the "<stylename>."
it will change the default widget's style) and they are managed / cutsomized using the Style
object.