首页 > 解决方案 > Tkinter - 使列自动调整为最长的字段值

问题描述

我正在制作一个简单的库存管理系统。我希望列自动调整为longest field value列中的。是当前的解决方案。我希望它是这样的。

这就是我初始化树视图的方式:

        self.tree = ttk.Treeview (height = 15, columns = ('amount',
        'size','price','status','best','comment'))
        self.tree.grid (row = 9, column = 0, columnspan = 7)
        self.tree.heading ('#0', text = 'Varenavn', anchor = W)
        self.tree.heading ('amount', text = 'Antall', anchor = W)
        self.tree.heading ('size', text = 'Størrelse', anchor = W)
        self.tree.heading ('price', text = 'Pris', anchor = W)
        self.tree.heading ('status', text = 'Status', anchor = W)
        self.tree.heading ('best', text = 'Best før', anchor = W)
        self.tree.heading ('comment', text = 'Kommentar', anchor = W)

我读过一列的默认值是我想要的行为。我在这里做错了什么?任何帮助将不胜感激!

标签: python-3.xtkinter

解决方案


推荐阅读