【问题标题】:How to make Treeview using python tkinter with just 3 rows. By default treeview is displayed which has many row如何使用只有 3 行的 python tkinter 制作 Treeview。默认情况下会显示包含多行的树视图
【发布时间】:2021-01-02 09:59:56
【问题描述】:

我想做三行的树形视图,表格的大小应该是三行 我尝试了以下代码

    tv1 = ttk.Treeview(self)
    tv1['columns'] = ('Expiry','Name')
    tv1.heading("#0", text='Symbol', anchor='center')
    tv1.column("#0", anchor="center")
    tv1.heading('Expiry', text='Expiry')
    tv1.column('Expiry', anchor='center', width=100)
    tv1.heading('Name', text='Full Name')
    tv1.column('Name', anchor='center', width=100)
    tv1.grid(row=0,column=12,sticky='n')
    init.treeview1 = tv1
    self.grid_rowconfigure(0, weight = 1)
    self.grid_columnconfigure(0, weight = 1)

【问题讨论】:

  • 树视图有一个记录在案的height 属性。你试过用吗?
  • 不,谢谢你的建议,我会试试的。

标签: python tkinter treeview


【解决方案1】:

只需将height 分配为 3

tv1 = ttk.Treeview(self, height=3)

您应该阅读这个简单的documentation 以了解更多此类性质的问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-07-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多