[英]How to change ttk.Treeview column width and weight in Python 3.3
我已經使用 Tkinter 為我的應用程序創建了一個 GUI。 我也在使用樹視圖小部件。 但是我無法更改其列寬和權重。 如何正確操作?
樣本:
tree = Treeview(frames[-1],selectmode="extended",columns=("A","B"))
tree.heading("#0", text="C/C++ compiler")
tree.column("#0",minwidth=0,width=100)
tree.heading("A", text="A")
tree.column("A",minwidth=0,width=200)
tree.heading("B", text="B")
tree.column("B",minwidth=0,width=300)
據我所知,它應該創建三個寬度為 100,200 和 300 的列。但是不會發生這樣的事情。
Treeview.Column
沒有weight
選項,但您可以將stretch
選項設置為False
以防止調整列大小。
from tkinter import *
from tkinter.ttk import *
root = Tk()
tree = Treeview(root, selectmode="extended", columns=("A", "B"))
tree.pack(expand=YES, fill=BOTH)
tree.heading("#0", text="C/C++ compiler")
tree.column("#0", minwidth=0, width=100, stretch=NO)
tree.heading("A", text="A")
tree.column("A", minwidth=0, width=200, stretch=NO)
tree.heading("B", text="B")
tree.column("B", minwidth=0, width=300)
root.mainloop()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.