python - 删除 tkinter TreeView 中的标题行

标签 python tkinter treeview ttk

谁能告诉我如何删除 tkinter Treeview 中的标题行?

from tkinter import *
from tkinter import ttk

root = Tk()

NewTree= ttk.Treeview(root)
NewTree.pack()
NewTree.heading("#0", text="How to remove this row?")
NewTree.insert("", "0", 'item1',text='Item number 1')

root.mainloop()

最佳答案

使用 show 选项只显示树而不显示标题:

NewTree = ttk.Treeview(root, show="tree")

相关文档

来自 docs.python.org :

show

A list containing zero or more of the following values, specifying which elements of the tree to display.

  • tree: display tree labels in column #0.
  • headings: display the heading row.

The default is “tree headings”, i.e., show all elements.

Note: Column #0 always refers to the tree column, even if show=”tree” is not specified.

来自New Mexico Tech Tkinter reference :

show

To suppress the labels at the top of each column, specify show='tree'. The default is to show the column labels.

来自 TkDocs :

You can optionally hide one or both of the column headings or the tree itself (leaving just the columns) using the show widget configuration option (default is "tree headings" to show both).

关于python - 删除 tkinter TreeView 中的标题行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51762835/

相关文章:

python - 如何停止打印播放功能?

python - 重新采样数据框以添加缺失的日期

python - 如何进行 ttk.Combobox 回调

.net - TreeView 虚拟化

c# - WPF TreeView : Skip a Level

python list_composition获取多个值

python - Python map(None, fcn()) 是否有更简单的构造?

python - 为什么创建弹出窗口时我的 Canvas 上的绘图没有出现?

python - 为什么在 tkinter 上销毁两个不同的主循环窗口会卡住程序?

wpf - 如何使TreeViewItem上的IsMouseOver的WPF触发器不影响moused-over控件的所有父级?