python - 如何使用 GUI Tkinter 和 Pandas 在 Excel 中添加数据
问题描述
嗨,我想通过单击添加按钮将数据添加到 Excel 工作表。我正在将 tkinter 用于 GUI 和 pandas 以使用 excel。我尝试了 get() 方法从输入字段中获取数据并将其添加到 Excel 工作表中。但是我在excel表中看不到任何东西。请帮忙。我的代码如下。
============
from tkinter import *
import pandas as pd
def UpdateSheet():
writer = pd.ExcelWriter("Match1.xlsx")
var.get(writer)
writer.save()
top2=Tk()
top2.geometry("800x800")
var = StringVar()
t2name = Label(top2, text="Team 2 name").place(x=20, y=30)
t2entry = Entry(top2, width=30,textvariable=var).place(x=100, y=30)
sbtbtn2 = Button(top2, text="Submit", activebackground='Orange', activeforeground='Black',
command=UpdateSheet).place(x=100, y=500)
top2.mainloop()
解决方案
推荐阅读
- php - 如何在 WooCommerce 中获取产品的品牌名称
- c# - 是否可以使用git标记所有文件
- azure - 如何将 .yml 作业脚本作为单个任务,作为具有其他步骤的管道的一部分?
- php - 没有这样的元素:无法找到元素:{"method":"css selector","selector":"body select[name='Accept']"}
- doctrine - mysql 函数的本机查询或 DoctrineExtensions
- azure - 由于资源提供程序注册错误,无法创建 Azure Web App Bot
- android - ERROR: Could not find org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.31
- php - 通过 WooCommerce 中的功能显示高级自定义字段
- php - 播种/创建多对多关系
- excel - export-csv powershell后格式化excel文件