Reputation: 570
Even though my Treeview has the option takefocue=False
, the text in the cells is still taking focus somehow. Specifically the text column when I do tree.insert('', tk.END, text='Some Text', values=5)
is taking focus, meaning there is a dashed line around Some Text
. I was able to find this resource, but I am not sure of the layout string I need to change.
Upvotes: 3
Views: 2289
Reputation: 2643
According to the Tcl/Tk wiki, the following 5 styles can be used to customize a ttk.Treeview()
widget:
"Treeview"
"Treeview.Heading"
"Treeview.Row"
"Treeview.Cell"
"Treeview.Item"
Using .layout()
, you can retrieve the layout specifications of each style:
style = ttk.Style()
style.layout("Treeview.Item")
It turns out that the "Treeview.Item"
style has a "Treeitem.focus"
layout mark. If you comment it out when overwriting the layout, the focus drawing behavior (and the dashed line) will disappear:
style = ttk.Style()
style.layout("Treeview.Item",
[('Treeitem.padding', {'sticky': 'nswe', 'children':
[('Treeitem.indicator', {'side': 'left', 'sticky': ''}),
('Treeitem.image', {'side': 'left', 'sticky': ''}),
#('Treeitem.focus', {'side': 'left', 'sticky': '', 'children': [
('Treeitem.text', {'side': 'left', 'sticky': ''}),
#]})
],
})]
)
Upvotes: 5