我收到此错误:AttributeError:'NoneType'对象没有属性'get' 使用此程序时:
from random import *
from time import *
from tkinter import *
MyWindow = Tk()
MyWindow.title('Fruit Machine')
MyWindow.geometry("1000x1000")
money=0
Heading=StringVar()
Heading1=StringVar()
Heading.set("Starting fruit machine simulator!")
Heading1.set("Important: Do not enter words or symbols!")
TitleText=Label(MyWindow,textvariable=Heading,bg="blue",fg="white",font=("Arial",14)).place(x=200,y=200)
TitleText=Label(MyWindow,textvariable=Heading1,bg="blue",fg="white",font=("Arial",14)).place(x=200,y=230)
Name=StringVar()
InputBox=Entry(MyWindow,textvariable=Name,width="25",font=("Arial",14)).place(x=200,y=260)
def set_money():
money = InputBox.get()
#b = Button(MyWindow, text="Press Me", command = lambda: setattr(,'money', 7), height=10, width=10, compound=LEFT)
b = Button(MyWindow, text="Press Me", command = set_money, height=10, width=10, compound=LEFT)
b.place(x = 200, y = 280)
mainloop()
我试图在用户单击按钮时更新可变项。 有人可以帮忙吗? 我看着这里:Tkinter: AttributeError: NoneType object has no attribute get 但是我不明白! 请帮助