Search code examples
pythonpython-3.xtkintertreeview

_tkinter.TclError: Layout PViewStyle not found


I am having trouble defining a Style for my Treeview widget.

newT=ttk.Style() 
newT.configure('PViewStyle', rowheight=100) 
PatrolView = ttk.Treeview(PatrolOverview,style='PViewStyle') 

but this yields

_tkinter.TclError: Layout PViewStyle not found

Solution

  • I get same error :). The problem is that name style must be end to correct name style in tkinter

    Widget class Style name
    Button TButton
    Checkbutton TCheckbutton
    Combobox TCombobox
    Entry TEntry
    ...
    Treeview Treeview (not TTreview!)
    https://anzeljg.github.io/rin2/book2/2405/docs/tkinter/ttk-style-layer.html

    In your case you need to name your style as PViewStyle.Treeview

    Change our code to:

    newT=ttk.Style() 
    newT.configure('PViewStyle.Treeview', rowheight=100) 
    PatrolView = ttk.Treeview(PatrolOverview,style='PViewStyle.Treeview')