我是 Tkinter 和 Python 3.3 的新手,并试图开发一个简单的 GUI。我有一个标签“statusLabel”。当我单击按钮时,我想更新按钮回调中标签中的值,但出现错误。
line 12, in reportCallback
statusLabel.config(text="Thank you. Generating report...")
AttributeError: 'NoneType' object has no attribute 'config'
下面是我的代码
from tkinter import *
root = Tk()
Label(root,text="Project folders. Include full paths. One project per line").pack()
Text(root,height=4).pack()
Label(root,text="Standard project subfolders. Include path from project.").pack()
Text(root,height=4).pack()
statusLabel = Label(root,text="Oh, hello.").pack()
def reportCallback():
statusLabel.config(text="Thank you. Generating report...")
b = Button(root, text="Generate Report", command=reportCallback).pack()
root.mainloop()