删除 tkinter 树视图中的标题行

编程入门 行业动态 更新时间:2024-10-26 06:29:14
本文介绍了删除 tkinter 树视图中的标题行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

谁能告诉我如何删除 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:

显示

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

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屋!

更多推荐

[db:关键词]

本文发布于:2023-04-30 06:59:46,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:视图   标题   tkinter

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!