|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
程 序 运 行 后 显 示 的 “人才组” 下 拉 菜 单 中,欲 要 点 击 “文件” (文件在 e:/Python/girl.xlsx), 怎 么 写 代 码 呀 ?
- from tkinter import *
- import pandas as pd
- root = Tk()
- root.title("个人娱乐计算机管理系统")
- root.config(background="beige")
- root.iconbitmap("e:/Python/11.ico")
- root.geometry("600x200+850+200")
- def callback():
- print("计算机程序完善中......")
- def wj():
- file_1=pd.read_excel("e:/Python/girl.xlsx")
- menubar=Menu(root) # 创建一个顶级菜单
- # 创建“人才组”下拉菜单,而后添加到顶级菜单中
- talentmenu=Menu(menubar,tearoff=False)
- talentmenu.add_command(label="成员",command=callback)
- talentmenu.add_command(label="文件",command=wj)
- talentmenu.add_command(label="考勤",command=callback)
- talentmenu.add_command(label="备用",command=callback)
- talentmenu.add_separator()
- talentmenu.add_command(label="退出",command=root.quit)
- menubar.add_cascade(label="人才组",menu=talentmenu)
- root.config(menu=menubar) # 显示菜单
- mainloop()
复制代码
核心代码
- def load():
- tree.delete(*tree.get_children())
- wb=load_workbook(r"2022.xlsx",data_only=True)
- ws=wb.active
- cres=ws["a1:d10"]
- for row in ws.iter_rows(min_row=1,max_row=10,max_col=4):
- i=1
- res=[cell.value for cell in row]
- tree.insert("",i,values=res)
- i+=1
-
- btnload=tkinter.Button(root,text="导入数据",command=load)
- btnload.place(x=160,y=530,width=100,height=40)
复制代码
|
|