简体   繁体   English

删除 tkinter 树视图中的标题行

[英]Remove header row in tkinter treeview

Can anyone tell me how to remove the header row in a tkinter Treeview?谁能告诉我如何删除 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()

Use the show option to only show the tree and not the heading:使用show选项只显示树而不显示标题:

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

Relevant documentation相关文件

From docs.python.org :来自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.树:在第 0 列中显示树标签。
  • headings: display the heading row.标题:显示标题行。

The default is “tree headings”, ie, show all elements.默认为“树标题”,即显示所有元素。

Note : Column #0 always refers to the tree column, even if show=”tree” is not specified.注意:列 #0 始终指的是树列,即使未指定 show=”tree”。

From the New Mexico Tech Tkinter reference :来自新墨西哥技术 Tkinter 参考

show展示

To suppress the labels at the top of each column, specify show='tree' .要抑制每列顶部的标签,请指定show='tree' The default is to show the column labels.默认是显示列标签。

From TkDocs :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).您可以选择使用show小部件配置选项隐藏一个或两个列标题或树本身(只保留列)(默认为"tree headings"以显示两者)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM