删除 tkinter 树视图中的标题行 [英] Remove header row in tkinter treeview

查看:36
本文介绍了删除 tkinter 树视图中的标题行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Can anyone tell me how to remove the header row in a 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 选项只显示树而不显示标题:

Use the show option to only show the tree and not the heading:

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


相关文档

来自 docs.python.org:

显示

包含零个或多个以下值的列表,指定要显示树的哪些元素.

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

  • tree:在第 0 列中显示树标签.
  • headings:显示标题行.

默认为树标题",即显示所有元素.

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

注意:列 #0 始终指的是树列,即使未指定 show="tree".

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

来自 新墨西哥技术 Tkinter 参考:

显示

要抑制每列顶部的标签,请指定 show='tree'.默认是显示列标签.

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

来自 TkDocs:

您可以选择使用 show 小部件配置选项隐藏一个或两个列标题或树本身(仅保留列)(默认为 树标题" 显示两者).

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).

这篇关于删除 tkinter 树视图中的标题行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆