I have a ttk.Notebook
and each tab contains a ttk.Treeview
. All treeviews have the same columns but contain different items, like in the code below.
import tkinter as tk
from tkinter import ttk
root = tk.Tk()
notebook = ttk.Notebook(root)
notebook.pack()
tree1 = ttk.Treeview(notebook, columns=['a', 'b', 'c'])
tree1.insert('', 'end', text='item1', values=('a1', 'b1', 'c1'))
tree2 = ttk.Treeview(notebook, columns=['a', 'b', 'c'])
tree2.insert('', 'end', text='item2', values=('a2', 'b2', 'c2'))
tree2.insert('', 'end', text='item2', values=('a2', 'b2', 'c2'))
notebook.add(tree1, text='Tab 1')
notebook.add(tree2, text='Tab 2')
root.mainloop()
I would like all trees to always have the same column widths. So, for instance, when the user resizes the column 'a' of tree1
, the column 'a' of tree2
should be resized too.
I know I can get the size of a column with
tree1.column('a', 'width')
and set it with tree2.column('a', width=300)
.
But how can I detect that the size of a column has changed?
I have checked that the treeview <Configure>
event is not triggered by a column resizing.