📜  python 3 tkinter 树视图示例 - Python 代码示例

📅  最后修改于: 2022-03-11 14:47:08.726000             🧑  作者: Mango

代码示例1
# How to create a basic Treeview
tv = Treeview(self)          # could also include columns with
tv['columns'] = 'Column2'    # Treeview(master, column=('yourcolumnname'))
tv.heading('#0', text='Heading1')  # '#0' standard name for the first column
tv.heading('Column2', text='I am the SECOND column')
parentrow = tv.insert('', 0, text="ParentRow", values=1)
tv.insert(parentrow, 1, text="Level2", values=2)  # subrow
tv.pack()

# if you put a tuple for values, then they will be iterated for each of your columns
# example in this Treeview tv:
tv['columns'] = ('C2', 'C3')
tv.insert('', 2, text='proove', values=('for', 'you'))

# sidenote: in the example I found they used 'end' as index for the subrow