我正在创建一个计数器,以计算用户上载CSV文件时有多少个空单元格。我也正在使用treeview显示CSV的内容。该print("There are", emptyCells.sum(), "empty cells")
作品并将其打印到控制台,但我想将其显示在标签中,以便用户可以在GUI中查看。它不显示任何内容,而是"row"
在文件上传后将a添加到应用程序中,其中的标签应该是一切都向下移动但没有内容插入标签中。
emptyCells = (df[df.columns] == " ").sum()
# print("There are", emptyCells.sum(), "empty cells")
tree.pack(side=BOTTOM, pady=50)
messagebox.showinfo("Success", "File Uploaded Successfully")
stringVariable = StringVar()
printVariable = ("There are", emptyCells.sum(), "empty cells")
#print(printVariable)
stringVariable.set(printVariable)
lbl = Label(windowFrame, textvariable=stringVariable, font=25)
lbl.pack()
根据您的问题,您想label
通过单击按钮来更新tkinter 。您可以使用以下方式进行此操作:
from tkinter import *
from tkinter import messagebox
root = Tk(className="button_click_label")
root.geometry("200x200")
messagebox.showinfo("Success","Test")
emptyCells = (df[df.columns] == " ").sum()
l1 = Label(root, text="Emptycells?")
def clickevent():
txt = "there are", emptyCells
l1.config(text=txt)
b1 = Button(root, text="clickhere", command=clickevent).pack()
l1.pack()
root.mainloop()
它没有经过pandas
库测试,但是应该可以为您服务!
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句