pu369com

利用pandas 和 ttk.Treeviews制作xlsx视图工具

 

import tkinter as tk
from tkinter import ttk
import pandas as pd
import tkinter.messagebox as msgbox

def Start():
    msgbox.showinfo('提示', 'OK')
    fp = pd.read_excel("./test.xlsx")
    for i in tree.get_children():
        tree.delete(i)
    for _ in range(len(fp.index.values)):
        tree.insert('','end',value=tuple(fp.iloc[_,[0,1,2]].values))        

win = tk.Tk()
#win.wm_attributes('-topmost',1)
win.geometry("300x1000+10+10")
#ttk.Button(win,text="Import it",command=Start).pack()
columns = ("A","B","C")
tree = ttk.Treeview(win,show="headings",columns=columns,height=45)
tree.column("A",width=100,anchor='center')
tree.heading("A",text="列A")
tree.pack()
win.after(500,Start)

win.mainloop()

  

 

 

参考:https://blog.csdn.net/weixin_43849588/article/details/104968231

posted on 2023-04-11 18:25  pu369com  阅读(64)  评论(0编辑  收藏  举报

导航