Python GUI編程(Tkinter)20、表格數據


import tkinter
from tkinter import ttk

win = tkinter.Tk()
win.title("sunck")
win.geometry("600x400+200+20")

#表格
tree = ttk.Treeview(win)
tree.pack()

#定義列
tree["columns"] = ("姓名", "年齡", "身高", "體重")
#設置列,列還不顯示
tree.column("姓名", width=100)
tree.column("年齡", width=100)
tree.column("身高", width=100)
tree.column("體重", width=100)

#設置表頭
tree.heading("姓名", text="姓名-name")
tree.heading("年齡", text="年齡-age")
tree.heading("身高", text="身高-height")
tree.heading("體重", text="體重-weight")

#添加數據
tree.insert("", 0, text="line1", values=("陸彥旭","28","165","80"))
tree.insert("", 1, text="line2", values=("范育賓","29","167","70"))


win.mainloop()


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM