如何使用 python tkinter 制作只有 3 行的 Treeview。默认情况下显示有很多行的树视图

How to make Treeview using python tkinter with just 3 rows. By default treeview is displayed which has many row

我想制作只有三行的树视图,table 的大小应该是 3 行 我尝试了以下代码

    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 分配为 3

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

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