我希望我的树形视图能够完全适应我为GUI定义的窗口的几何大小,但显示内容并没有覆盖整个窗口,而是显示在中间位置。
from tkinter import ttk
import tkinter as tk
root = tk.Tk()
root.geometry("1200x680+50+20")
tree = ttk.Treeview(root)
tree.insert("", "0", "item1", text="LANGUAGE")
tree.insert("", "1", "item2", text="GUI")
tree.insert("item1", "0", text="pyhton")
#SUb treeview
style = ttk.Style(root)
style.configure("Treeview", rowheight=70)
tree.configure(style="Treeview")
############
tree.config(columns=("NOTE", "book")) # this creates to seperate headings
for treeview
tree.column("NOTE", width=300)
tree.heading("NOTE", text="Info")
tree.column("book", width=300)
tree.heading("book", text="profile")
tree.set("item1", "NOTE","Am using python version 3.6.1 \n on windows
machine")
tree.set("item2","NOTE","This an example Tkinter Treeview in Python, which
is from \nttk class make sure import ttk\n also from tkinter import *")
tree.pack()
root.mainloop()
我试图将它放在一个框架中,但这也不能显示树视图的内容。以下是代码:
fr = tk.Frame(root, width=1200, height=680, relief="groove")
tree = ttk.Treeview(fr)
fill='both'
。 - Bryan Oakley