Why do treeview widget put an extra column although I only gave it two? I also can't control the width of it

前端 未结 1 1127
南旧
南旧 2020-12-21 23:21
  1. I can\'t figure out how to control the width of the widget
  2. I can\'t make it display only 2 columns

    from Tkinter import *
    from ttk import Tr         
    
    
            
相关标签:
1条回答
  • 2020-12-21 23:56

    That first column is the tree. You can turn it off by using the show attribute. The value must be a list with zero or more values. The valid values are headings to show the column headings, and tree to show the tree. The default value is ['tree', 'headings'].

    Here's how to have the treeview show the column headings but not the tree:

    tree = Treeview(root, height=10, columns=2, show=["headings"])
    

    If you want to see the tree, but you want to control its width, you can do that too. The tree column can always be identified with '#0'. You can use the column method to set the width:

    tree.column('#0', width=50)
    
    0 讨论(0)
提交回复
热议问题