让我的树视图填充创建的顶层窗口时遇到了挑战,尝试了 fill="x" 和 fill="both" 但没有得到结果。任何建议这样做。
from tkinter import ttk
import tkinter as tk
def my_treeview():
mt = tk.Toplevel()
mt.geometry("1000x580")
tree = ttk.Treeview(mt)
tree.insert("", "0", "item1", text="fill width")
tree.insert("", "1", "item2", text="fill height")
tree.pack(fill="both")
root = tk.Tk()
root.geometry("400x400")
treeview = tk.Button(root, text="open treeview", command=my_treeview).pack()
root.mainloop()