Tkinter Treeview最右边的列在调整大小时表现不正常

时间:2017-04-28 10:35:06

标签: python python-3.x tkinter treeview

如下面的GIF所示,我树视图的最右侧列未附加'到右边界。为什么是这样?代码在底部。

enter image description here

    self.tree.grid(row=1, column=0, sticky='NSEW', padx=3, pady=2)
    self.tree.configure(yscrollcommand=self.tree_scroll.set)
    self.tree_scroll.configure(command=self.tree.yview)

    self.heading('#0', text="Name", anchor='center')
    self.heading('version', text="Version", anchor='center')
    self.heading('author', text="Author", anchor='center')
    self.heading('description', text="Description", anchor='center')
    self.heading('runtime', text="Run Time", anchor='center')
    self.heading('maxtime', text="Max Time", anchor='center')
    self.heading('status', text="Status", anchor='center')
    self.column('#0', width=140, stretch=False)
    self.column('version', width=80, stretch=False)
    self.column('author', width=120, stretch=False)
    self.column('description', width=440)
    self.column('runtime', width=100, stretch=False)
    self.column('maxtime', width=100, stretch=False)
    self.column('status', width=100, stretch=False)

2 个答案:

答案 0 :(得分:0)

您好,我不知道列的类型,但

你不能做那样的事吗?

self.column('status', width=parent.width - self.column('#0').widht  - self.column('version').width - ...etc..., stretch=False)

答案 1 :(得分:0)

container = Frame()
container.pack(expand=True)

假设您的树在容器中